-
Notifications
You must be signed in to change notification settings - Fork 0
/
predictive_algorithm.rq
45 lines (44 loc) · 1.68 KB
/
predictive_algorithm.rq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX ldmc-p: <http://ldmc.org/p/>
PREFIX ldmc: <http://ldmc.org/ontology/>
SELECT ?film ?id (AVG(?percentGood * (?multiple + ?topBottom)) AS ?percent) (IF(?percent > 55,"good","bad") AS ?Label)
WHERE {
?film a ldmc:testing_data .
?film ?p ?o .
?film ldmc-p:id ?id .
FILTER NOT EXISTS { ?o a ldmc:drop . }
FILTER NOT EXISTS { ?p a ldmc:drop . }
{
SELECT ?o ?multiple (COUNT(DISTINCT ?film1) AS ?Gcount) (COUNT(DISTINCT ?film2) AS ?Bcount) ((?Gcount/(?Gcount + ?Bcount)) * 100 AS ?percentGood)
WHERE {
{
?film1 a ldmc:training_data .
?film1 ldmc-p:rating "good" .
?film1 ?p ?o .
BIND(IF(regex(STR(?o),"award|_board_|film_critic|AFI\\'s|BAFTA|Criterion_Collection|American_Cinema_Editors|Sony_Pictures_Classics|documentary","i"),6,1) AS ?multiple) .
FILTER NOT EXISTS { ?o a ldmc:drop . }
FILTER NOT EXISTS { ?p a ldmc:drop . }
}
UNION
{
?film2 a ldmc:training_data .
?film2 ldmc-p:rating "bad" .
?film2 ?p ?o .
BIND(IF(regex(STR(?o),"award|_board_|film_critic|AFI\\'s|BAFTA|Criterion_Collection|American_Cinema_Editors|Sony_Pictures_Classics|documentary","i"),6,1) AS ?multiple) .
FILTER NOT EXISTS { ?o a ldmc:drop . }
FILTER NOT EXISTS { ?p a ldmc:drop . }
}
}
GROUP BY ?o ?multiple
}
BIND(IF(?percentGood > 75 && ?Gcount > 10,0.2,IF(?percentGood < 35 && ?Bcount > 10,-0.7,0)) AS ?topBottom) .
}
GROUP BY ?film ?id
ORDER BY ?id