Skip to content

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

Notifications You must be signed in to change notification settings

generall/sklearn-sknnsuite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages