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

ImportError: cannot import name 'pinv2' from 'scipy.linalg' #444

Open
Alan-Wolf-VN opened this issue Mar 13, 2023 · 1 comment
Open

ImportError: cannot import name 'pinv2' from 'scipy.linalg' #444

Alan-Wolf-VN opened this issue Mar 13, 2023 · 1 comment
Labels

Comments

@Alan-Wolf-VN
Copy link

Describe the bug
Cannot import TimeSeriesKMeans from tslearn.clustering. The reason can be that scipy.linalg.pinv2 was deprecated with version 1.7 and removed with version 1.9. The functionality has been subsumed by scipy.linalg.pinv:

ImportError Traceback (most recent call last)
C:\Users\NAMTRA~1\AppData\Local\Temp/ipykernel_9540/1246615330.py in
----> 1 from tslearn.clustering import TimeSeriesKMeans

~\AppData\Roaming\Python\Python39\site-packages\tslearn\clustering_init_.py in
6 details.
7 """
----> 8 from .kshape import KShape
9 from .utils import (EmptyClusterError, silhouette_score,
10 TimeSeriesCentroidBasedClusteringMixin)

~\AppData\Roaming\Python\Python39\site-packages\tslearn\clustering\kshape.py in
9 from tslearn.preprocessing import TimeSeriesScalerMeanVariance
10 from tslearn.utils import to_time_series_dataset, check_dims
---> 11 from tslearn.metrics import cdist_normalized_cc, y_shifted_sbd_vec
12 from tslearn.bases import BaseModelPackage, TimeSeriesBaseEstimator
13

~\AppData\Roaming\Python\Python39\site-packages\tslearn\metrics_init_.py in
15 sakoe_chiba_mask, itakura_mask,
16 lcss, lcss_path, lcss_path_from_metric)
---> 17 from .ctw import ctw_path, ctw, cdist_ctw
18 from .sax import cdist_sax
19 from .softdtw_variants import (cdist_soft_dtw, cdist_gak,

~\AppData\Roaming\Python\Python39\site-packages\tslearn\metrics\ctw.py in
----> 1 from sklearn.cross_decomposition import CCA
2 from .dtw_variants import dtw_path
3 from .utils import _cdist_generic
4 from ..utils import to_time_series
5 import numpy as np

~\Anaconda3\lib\site-packages\sklearn\cross_decomposition_init_.py in
----> 1 from ._pls import PLSCanonical, PLSRegression, PLSSVD, CCA
2
3 all = ['PLSCanonical', 'PLSRegression', 'PLSSVD', 'CCA']

~\Anaconda3\lib\site-packages\sklearn\cross_decomposition_pls.py in
10
11 import numpy as np
---> 12 from scipy.linalg import pinv2, svd
13
14 from ..base import BaseEstimator, RegressorMixin, TransformerMixin

To Reproduce
from tslearn.clustering import TimeSeriesKMeans

Expected behavior
import tslearn.clustering without any error message

Environment (please complete the following information):

  • OS: Windows 10
  • tslearn version 0.5.3.2
@VaishU2235
Copy link

VaishU2235 commented Mar 29, 2023

I was able to recreate the issue from my end using the following code:

!pip install scikit-learn==0.24
!pip install scipy==1.9
!pip install tslearn
from tslearn.clustering import TimeSeriesKMeans

This issue was fixed in scikit-learn 1.0.X

!pip install scikit-learn==1.0
!pip install scipy==1.9
!pip install tslearn
from tslearn.clustering import TimeSeriesKMeans

Is not throwing any errors for me. Please use scikit-learn>=1.0 to solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants