larsmans / seqlearn

Sequence learning toolkit for Python
http://larsmans.github.io/seqlearn/
MIT License
690 stars 101 forks source link

Sklearn compatibility #33

Open enricopal opened 7 years ago

enricopal commented 7 years ago

Hello, I was hoping to reuse the model selection routines of the Scikitlearn API (grid search CV and the like), but it appears that neither HMM nor the StructuredPerceptron are considered to be valid estimator (http://scikit-learn.org/stable/developers/contributing.html#rolling-your-own-estimator). By looking through the source code, everything seems to be abiding scikitlearn rules, but if I try:

from seqlearn.perceptron import StructuredPerceptron from sklearn.utils.estimator_checks import check_estimator model = StructuredPerceptron() check_estimator(model)

I get: AttributeError: 'StructuredPerceptron' object has no attribute 'name'

Any clue on how to fix this compatibility issue? Thanks a lot in advance, Enrico

vene commented 7 years ago

Hi Enrico,

Currently the check_estimator function takes a class, not an instance, so you need to run

check_estimator(StructuredPerceptron)

instead. We will add support for testing individual instances in the future, though.