-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluatestupidclassifier.py
37 lines (34 loc) · 1.73 KB
/
evaluatestupidclassifier.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
32
33
34
35
36
37
from classification import classifiers
from feature_extraction import dataloader
import evaluation
#import evaluation
import collections
goodwords = {'sentiment':[[], ['bad', 'sucks', 'awful', 'negative'], [], ['good', 'great', 'like', 'love', 'awesome'], []],
'time':[['is', 'are', 'now','present'], ['will', 'might', 'should','could', 'can', 'future'], [], ['did', 'had', 'went', 'happened','came', 'past', 'passed', 'was']],
'event':[['cloud'], ['cold'], ['dry'], ['hot'], ['humid'], ['hurricane'], [], ['ice'], [], ['rain'], ['snow'], ['storm'], ['sun'], ['tornado'], ['wind']]
}
loader = dataloader.DataLoader('data/train.csv')
testfeaturevectors = loader.extractFeatureVectors()
testlabelvectors = loader.extractLabelBitVectors(.5, None)
evaluator = evaluation.Evaluator()
testlabelvectors = loader.extractLabelBitVectors(.5, None)
factory = classifiers.StupidFactory()
for labeltype in goodwords:
onevallstupid = factory.getClassifier(goodwords[labeltype])
expectedvectors = testlabelvectors[labeltype]
predictedvectors = []
for example in testfeaturevectors:
predicted = onevallstupid.classify(example)
predictedvectors.append(predicted)
#print labeltype
#print 'numrows' ,len(predictedvectors)
#print 'numrows' ,len(expectedvectors)
#print 'predicted numcols', len(predictedvectors[0]),predictedvectors[0]
#print 'expected numcols', len(expectedvectors[0]), expectedvectors[0]
rmse = evaluator.rmse(predictedvectors, expectedvectors)
error_rate = evaluator.error_rate(predictedvectors, expectedvectors)
print 'rmse', labeltype, ' : ', rmse
print 'error_rate', labeltype, ' : ', error_rate
print labeltype, ' : ', rmse
#onevallstupid = Stupid_Factory(goodwords[labeltype])
#Get_Error(onevallstupid,testfeaturevectors, testlabelvectors)