• Stars
    star
    3
  • Rank 3,954,374 (Top 79 %)
  • Language
    Python
  • Created over 7 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Wrapper which provides scikit-learn-compatible implementation of SkNN sequence labeling algorithm

sklearn-SkNNSuite

Wrapper which provides scikit-learn-compatible implementation of SkNN sequence labeling algorithm.

SkNN is a metric algorithm for labeling\classification sequential data. It accepts for classification any type of sequence elements with only condition: you need to define distance function which can calculate distance between pair of elements.

Detailed description of SkNN could be found at arXiv.

Installation

TODO

Usage

from sknn_suite import SkNNSuite

clf = SkNNSuite(k=1, distance_function=lambda x, y: abs(x - y))

clf.fit(X=[
    [1, 100, 10, 11],
    [1, 50, 21, 20],
    [1, 2, 3, 4, 5]
], y=[
    ["l1", "l2", "l3", "l3"],
    ["l1", "l4", "l5", "l5"],
    ["l1", "l1", "l1", "l1", "l1"]
])

prediction = clf.predict(x_targets=[
    [1, 70, 0, 0],
    [1, 80, 23, 22],
    [1, float('inf'), 23, 22]
])

self.assertEqual(["l1", "l2", "l3", "l3"], prediction[0])
self.assertEqual(["l1", "l4", "l5", "l5"], prediction[1])
self.assertEqual(None, prediction[2])

References