Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added workaround for sklearn 0.24 #93

Merged
merged 1 commit into from
Apr 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion pyriemann/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@
import numpy
from sklearn.base import (BaseEstimator, ClassifierMixin, TransformerMixin,
ClusterMixin)
from sklearn.cluster._kmeans import _init_centroids

try:
from sklearn.cluster._kmeans import _init_centroids
except ImportError:
# Workaround for scikit-learn v0.24.0rc1+
# See issue: https://github.com/alexandrebarachant/pyRiemann/issues/92
from sklearn.cluster import KMeans

def _init_centroids(X, n_clusters, init, random_state, x_squared_norms):
if random_state is not None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, I'm a bit late with noticing this, but this seems wrong?

Should probably be if random_state is None:, right?

random_state = numpy.random.RandomState(random_state)
return KMeans(n_clusters=n_clusters)._init_centroids(
X,
x_squared_norms,
init,
random_state,
)


from joblib import Parallel, delayed

from .classification import MDM
Expand Down