sktime/sktime

[ENH] Import more estimators from hmmlearn

Open

#3363 aperta il 29 ago 2022

Vedi su GitHub
 (14 commenti) (0 reazioni) (0 assegnatari)Python (1192 fork)batch import
enhancementgood first issuemodule:detection

Metriche repository

Star
 (7162 star)
Metriche merge PR
 (Merge medio 26g 10h) (86 PR mergiate in 30 g)

Descrizione

hmmlearn is a nifty python package with a lot of different sci-kit learn like estimators for using HMM algorithms.

We now have a simple way to wrap and thus import new HMM estimators into sktime, and I thought that it could be a great task for anyone new to sktime or open source in general to get started with if you are looking for an easy issue to contribute.

The estimators which still need to be wrapped are:

  • CategoricalHMM
  • MultinomialHMM
  • PoissonHMM

Here is a rough guide for what needs to be done in order to wrap an estimator from hmmlearn:

  • in the sktime.annotations.hmm_learn file add your new estimator to the __all__ attribute list near the top of the file.
  • make a new class for your relevant hmmlearn estimator.
  • right before this new class add the code which will ignore the soft dependency warning: _check_soft_dependencies("hmmlearn.hmm", severity="warning")
  • copy over the docstring from hmmlearn into your new class. Here is where the code lives on Github and you can check it out there. (may need to look into both the __init__ function and the main class docstring in order to get both the Parameters section and the Attributes slash general description.
  • update the __init__ and _fit functions to properly collect and store all the attributes needed for your wrapped estimator. In _fit pass these parameters to a wrapped version of your estimator.
  • update the docstring example
  • update the get_test_params method with some relevant params for your new estimator.
  • add a quick test in test_hmm_learn that gaurantees your new wrapped estimator agrees with the estimator it is wrapping in hmmlearn. It will be important to make sure both implementations have the same random state.

To see an example of what this should look like please check out my recent PR (#3362) for GMMHMM which has all these steps in it. If you would like top take on an estimator just comment in this issue so other people know you are working on it! :)

Guida contributor