-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClassifyLive.py
31 lines (26 loc) · 1.04 KB
/
ClassifyLive.py
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
import pickle
from Config import *
from FeatureExtractorModule import *
from Example import *
print "Loading the model..."
pickledModelFileHandle = open(pickledModelFileName, 'rb')
svcModelLoaded = pickle.load(pickledModelFileHandle)
svcModel = svcModelLoaded['model']
print "Load and Set the feature extractors..."
pickledFeatureExtractorsFileHandle = open(pickledFeatureExtractorsFileName,'rb')
featureExtractors = pickle.load(pickledFeatureExtractorsFileHandle)
setFeatureExtractors(featureExtractors)
print "Read the test examples"
testingDataFileHandle = open(testingDataFileName,'rb')
exampleLines = testingDataFileHandle.readlines()
testingExamples = []
for example in exampleLines:
example = example.strip()
ex = Example("",example)
testingExamples.append(ex)
print "Extracting the features..."
testingClasses,testingFeatures = extractFeatures(testingExamples,False)
print "Inferencing..."
predictedClasses = svcModel.predict(testingFeatures)
for predictedClass in predictedClasses:
print "The type of the question is: "+ predictedClass