Commit d76c71c3 authored by Taddeus Kroes's avatar Taddeus Kroes

Some minor bug-/comment-fixes.

parent 0a4ff955
...@@ -57,6 +57,7 @@ class Classifier: ...@@ -57,6 +57,7 @@ class Classifier:
true_value = 0 if true_value == None else ord(true_value) true_value = 0 if true_value == None else ord(true_value)
#x = character.get_feature_vector(self.cell_size) #x = character.get_feature_vector(self.cell_size)
character.get_single_cell_feature_vector(self.neighbours) character.get_single_cell_feature_vector(self.neighbours)
#p = svm_predict([true_value], [character.feature], self.model, '-b 1')
p = svm_predict([true_value], [character.feature], self.model) p = svm_predict([true_value], [character.feature], self.model)
prediction_class = int(p[0][0]) prediction_class = int(p[0][0])
......
...@@ -57,7 +57,7 @@ class LocalBinaryPatternizer: ...@@ -57,7 +57,7 @@ class LocalBinaryPatternizer:
| (self.is_pixel_darker(y - 2, x - 1, value)) | (self.is_pixel_darker(y - 2, x - 1, value))
def create_features_vector(self): def create_features_vector(self):
'''Walk around the pixels in clokwise order, shifting 1 bit less at '''Walk around the pixels in clockwise order, shifting 1 bit less at
each neighbour starting at 7 in the top-left corner. This gives a 8-bit each neighbour starting at 7 in the top-left corner. This gives a 8-bit
feature number of a pixel''' feature number of a pixel'''
self.setup_histograms() self.setup_histograms()
......
#!/usr/bin/python #!/usr/bin/python
from cPickle import dump, load from cPickle import dump, load
from sys import argv, exit
from Classifier import Classifier from Classifier import Classifier
...@@ -16,7 +17,7 @@ classifier = Classifier(c=float(argv[1]), \ ...@@ -16,7 +17,7 @@ classifier = Classifier(c=float(argv[1]), \
neighbours=int(argv[3])) neighbours=int(argv[3]))
classifier.train(learning_set) classifier.train(learning_set)
print 'Loading test set' print 'Loading test set...'
test_set = load(file('test_set%s.dat' % argv[1], 'r')) test_set = load(file('test_set%s.dat' % argv[1], 'r'))
l = len(test_set) l = len(test_set)
matches = 0 matches = 0
...@@ -34,5 +35,5 @@ for i, char in enumerate(test_set): ...@@ -34,5 +35,5 @@ for i, char in enumerate(test_set):
print ' -- %d of %d (%d%% done)' % (i + 1, l, int(100 * (i + 1) / l)) print ' -- %d of %d (%d%% done)' % (i + 1, l, int(100 * (i + 1) / l))
print '\n%d matches (%d%%), %d fails' % (matches, \ print '\n%d matches (%d%%), %d fails' % (matches, \
int(100 * matches / len(test_set)), \ int(100 * matches / l), \
len(test_set) - matches) len(test_set) - matches)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment