Spaces:
Runtime error
Runtime error
Update predictor.py
Browse files- predictor.py +11 -1
predictor.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import csv
|
2 |
import time
|
3 |
import uuid
|
@@ -9,6 +11,9 @@ from Pinpoint.RandomForest import *
|
|
9 |
class predictor():
|
10 |
|
11 |
def __init__(self):
|
|
|
|
|
|
|
12 |
self.model = random_forest()
|
13 |
self.model.PSYCHOLOGICAL_SIGNALS_ENABLED = False # Needs LIWC markup
|
14 |
self.model.BEHAVIOURAL_FEATURES_ENABLED = False
|
@@ -20,6 +25,12 @@ class predictor():
|
|
20 |
baseline_training_dataset_location="LIWC2015 Results (Storm_Front_Posts).csv")
|
21 |
|
22 |
def predict(self, string_to_predict = None, username = "unknown"):
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
if string_to_predict == None:
|
25 |
raise Exception("No prediction material given...")
|
@@ -75,4 +86,3 @@ class predictor():
|
|
75 |
return True
|
76 |
else:
|
77 |
return False
|
78 |
-
|
1 |
+
# This file wraps around Pinpoint to provide simple prediction functionality.
|
2 |
+
|
3 |
import csv
|
4 |
import time
|
5 |
import uuid
|
11 |
class predictor():
|
12 |
|
13 |
def __init__(self):
|
14 |
+
'''
|
15 |
+
Constructor
|
16 |
+
'''
|
17 |
self.model = random_forest()
|
18 |
self.model.PSYCHOLOGICAL_SIGNALS_ENABLED = False # Needs LIWC markup
|
19 |
self.model.BEHAVIOURAL_FEATURES_ENABLED = False
|
25 |
baseline_training_dataset_location="LIWC2015 Results (Storm_Front_Posts).csv")
|
26 |
|
27 |
def predict(self, string_to_predict = None, username = "unknown"):
|
28 |
+
'''
|
29 |
+
A wrapper function used to call pinpoint and predict if a given piece of text is extremist.
|
30 |
+
:param string_to_predict:
|
31 |
+
:param username:
|
32 |
+
:return: boolean true/ false
|
33 |
+
'''
|
34 |
|
35 |
if string_to_predict == None:
|
36 |
raise Exception("No prediction material given...")
|
86 |
return True
|
87 |
else:
|
88 |
return False
|
|