The eval()
method under sklearn.mixture.GMM
from the scikit-learn version 0.11 is deprecated. Is there a similar method or a workaround in the newest version 0.19.2 ?
3 回答
From the docs of an older scikit-learn version you can read the following:
DEPRECATED: GMM.eval was renamed to GMM.score_samples in 0.14 and will be removed in 0.16.
So I think you should use score_samples()
.
Eval(X)
Parameters :
X: array_like, shape (n_samples, n_features) : List of n_features-dimensional data points. Each row corresponds to a single data point.
Returns :
logprob: array_like, shape (n_samples,) : Log probabilities of each data point in X
responsibilities: array_like, shape (n_samples, n_components) :
Posterior probabilities of each mixture component for each observation
Clearly , there is no workaround in the newer definition , it is the same and quite concise definition
The current method to get the responsibilities is predict_proba()
predict_proba()
: Predict posterior probability of each component given the data.
Now you may think that the description does not say responsibilities. But this is what you need.
The move from GMM to GaussianMixture class has been discussed thoroughly here:
- https://github.com/taborlab/FlowCal/issues/230
- https://github.com/scikit-learn/scikit-learn/wiki/GSoC-2015-Proposal:-Improve-GMM-module
And the answer you need is described here:
You may see some difference in results as described by the author in this comment
The old one had a pretty strong regularization, the new one does not (by default).
You can check the source code too to verify that this indeed returns the responsibilities.