Skip to content

Commit

Permalink
Added SVM fix for bigrams+
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjalv123 committed Jan 17, 2012
1 parent a4519aa commit ae01710
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classifier.py
Expand Up @@ -149,7 +149,7 @@ def vectorToString(self, vec, cls = False):
# granted, this is kind of silly
# creates a string of the format "[class if point is labeled] feature1:value1 feature2:value2..."
# where the only allowed features are the ones in restrictFeatures, if we're restricting the features
return ((str(cls) + " ") if cls else "") + " ".join([str(i) + ":" + str(vec[i])
return ((str(cls) + " ") if cls else "") + " ".join(["-".join(str(i).split()) + ":" + str(vec[i])
for i in vec if (not self.restrictFeatures) or (i in self.restrictFeatures)]) + "\n"

def addFeatureVector(self, point, cls, binary=False):
Expand Down
6 changes: 3 additions & 3 deletions movie.py
Expand Up @@ -115,10 +115,10 @@ def test(classif, n=1, train_size=500, mode='k', iterations=1, dataset='', limit
if __name__ == "__main__":
#test(classifier.BayesClassifier,n=[1],train_size=800,mode='k',
# iterations=3,dataset='position',limit=[16165],binary=True)
#test(classifier.LinearSVMClassifier,n=[2],train_size=800,mode='k',
# iterations=3,dataset='default',limit=[16165],binary=True)
test(classifier.MaximumEntropyClassifier,n=[1],train_size=800,mode='k',
test(classifier.LinearSVMClassifier,n=[2],train_size=800,mode='k',
iterations=3,dataset='default',limit=[16165],binary=True)
#test(classifier.MaximumEntropyClassifier,n=[1],train_size=800,mode='k',
# iterations=3,dataset='default',limit=[16165],binary=True)

# with train_size = 800, no shuffling, bayes classifier
# [ns] dataset [limits] binary --> +results -results
Expand Down

0 comments on commit ae01710

Please sign in to comment.