Esempio n. 1
0
 def test(self, image, char=None):
     coms = connected_components(image)
     com = largest_component(coms)
     x = params_from_component(com, with_one=False)
     indexes, errors = self.kdtree.knn(x, self.k)
     scores = {lab: 0.0 for lab in self.label_set}
     for i in indexes[0]:
         scores[self.labels[i]] += 1.0 / self.k
     del scores['']
     return KNNClassifications(scores)
Esempio n. 2
0
File: ml_test.py Progetto: d5h/pyocr
def test(image, char=None):
    classifications = MLClassifications()
    coms = connected_components(image)
    com = largest_component(coms)
    xs = params_from_component(com, with_one=True)
    for c, ws in models.items():
        s = dot(ws, Trainer.get_transformed_data(xs, polynomial_transform_order))
        print c, s
        classifications.add(c, s)

    return classifications