8000 MAINT deprecate HMMs · mohitsingh1007/scikit-learn@c77255f · GitHub
[go: up one dir, main page]

Skip to content

Commit c77255f

Browse files
jaquesgroblerlarsmans
authored andcommitted
MAINT deprecate HMMs
Fixes scikit-learn#2731.
1 parent 5847006 commit c77255f

File tree

5 files changed

+50
-4
lines changed

5 files changed

+50
-4
lines changed

doc/modules/hmm.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Hidden Markov Models
66

77
.. currentmodule:: sklearn.hmm
88

9+
.. warning::
10+
11+
The `sklearn.hmm` module has now been deprecated due to it no longer matching
12+
the scope and the API of the project. It is scheduled for removal in the
13+
0.17 release of the project. Discussions are still underway regarding
14+
moving this module to a seperate repository.
15+
16+
917
`sklearn.hmm` implements the Hidden Markov Models (HMMs).
1018
The HMM is a generative probabilistic model, in which a sequence of observable
1119
:math:`\mathbf{X}` variable is generated by a sequence of internal hidden

doc/whats_new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
Changelog
99
---------
1010

11+
- :mod:`sklearn.hmm` is deprecated. Its removal is planned
12+
for the 0.17 release.
13+
1114
- Use of :class:`covariance.EllipticEnvelop` has now been removed after
1215
deprecation.
1316
Please use :class:`covariance.EllipticEnvelope` instead.

examples/applications/plot_hmm_stock_analysis.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
It uses stock price data, which can be obtained from yahoo finance.
88
For more information on how to get stock prices with matplotlib, please refer
99
to date_demo1.py of matplotlib.
10+
11+
.. warning::
12+
13+
The HMM module and its functions will be removed in 0.17
14+
as it no longer falls within the project's scope and API.
15+
1016
"""
1117

1218
from __future__ import print_function

examples/plot_hmm_sampling.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
between them. We can see that, as specified by our transition matrix,
1111
there are no transition between component 1 and 3.
1212
13+
.. warning::
14+
15+
The HMM module and its functions will be removed in 0.17
16+
as it no longer falls within the project's scope and API.
17+
1318
"""
1419
print(__doc__)
1520

sklearn/hmm.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
The :mod:`sklearn.hmm` module implements hidden Markov models.
99
1010
**Warning:** :mod:`sklearn.hmm` is orphaned, undocumented and has known
11-
numerical stability issues. If nobody volunteers to write documentation and
12-
make it more stable, this module will be removed in version 0.11.
11+
numerical stability issues. This module will be removed in version 0.17.
1312
"""
1413

1514
import string
@@ -37,9 +36,14 @@
3736
decoder_algorithms = ("viterbi", "map")
3837

3938

39+
@deprecated("WARNING: The HMM module and its functions will be removed in 0.17"
40+
"as it no longer falls within the project's scope and API.")
4041
def normalize(A, axis=None):
4142
""" Normalize the input array so that it sums to 1.
4243
44+
WARNING: The HMM module and its functions will be removed in 0.17
45+
as it no longer falls within the project's scope and API.
46+
4347
Parameters
4448
----------
4549
A: array, shape (n_samples, n_features)
@@ -65,6 +69,8 @@ def normalize(A, axis=None):
6569
return A / Asum
6670

6771

72+
@deprecated("WARNING: The HMM module and its function will be removed in 0.17"
73+
"as it no longer falls within the project's scope and API.")
6874
class _BaseHMM(BaseEstimator):
6975
"""Hidden Markov Model base class.
7076
@@ -75,6 +81,11 @@ class _BaseHMM(BaseEstimator):
7581
See the instance documentation for details specific to a
7682
particular object.
7783
84+
.. warning::
85+
86+
The HMM module and its functions will be removed in 0.17
87+
as it no longer falls within the project's scope and API.
88+
7889
Attributes
7990
----------
8091
n_components : int
@@ -152,8 +163,6 @@ def __init__(self, n_components=1, startprob=None, transmat=None,
152163
self._algorithm = algorithm
153164
self.random_state = random_state
154165

155-
@deprecated("HMM.eval was renamed to HMM.score_samples in 0.14 and will be"
156-
" removed in 0.16.")
157166
def eval(self, X):
158167
return self.score_samples(X)
159168

@@ -600,6 +609,11 @@ class GaussianHMM(_BaseHMM):
600609
This class allows for easy evaluation of, sampling from, and
601610
maximum-likelihood estimation of the parameters of a HMM.
602611
612+
.. warning::
613+
614+
The HMM module and its functions will be removed in 0.17
615+
as it no longer falls within the project's scope and API.
616+
603617
Parameters
604618
----------
605619
n_components : int
@@ -888,6 +902,11 @@ def fit(self, obs):
888902
class MultinomialHMM(_BaseHMM):
889903
"""Hidden Markov Model with multinomial (discrete) emissions
890904
905+
.. warning::
906+
907+
The HMM module and its functions will be removed in 0.17
908+
as it no longer falls within the project's scope and API.
909+
891910
Attributes
892911
----------
893912
n_components : int
@@ -1081,6 +1100,11 @@ def fit(self, obs, **kwargs):
10811100
class GMMHMM(_BaseHMM):
10821101
"""Hidden Markov Model with Gaussin mixture emissions
10831102
1103+
.. warning::
1104+
1105+
The HMM module and its functions will be removed in 0.17
1106+
as it no longer falls within the project's scope and API.
1107+
10841108
Attributes
10851109
----------
10861110
init_params : string, optional

0 commit comments

Comments
 (0)
0