Closed
Description
Describe the bug
sklearn.cross_decomposition.PLSRegression
fails to fit some data with StopIteration
.
Steps/Code to Reproduce
import numpy as np
from sklearn.cross_decomposition import PLSRegression
dataset = np.load("plsRegression.npz")
x = dataset["x"] # x.shape = (10, 12)
y = dataset["y"] # y.shape = (10,)
model = PLSRegression(n_components=5)
model.fit(x, y)
Expected Results
PLSRegression
completes fit()
without error or with a more descriptive error.
Actual Results
/path/to/my/venv/lib64/python3.9/site-packages/sklearn/cross_decomposition/_pls.py:62: RuntimeWarning: invalid value encountered in true_divide
y_weights = np.dot(Y.T, x_score) / np.dot(x_score.T, x_score)
/path/to/my/venv/lib64/python3.9/site-packages/sklearn/cross_decomposition/_pls.py:263: RuntimeWarning: invalid value encountered in true_divide
x_loadings = np.dot(x_scores, Xk) / np.dot(x_scores, x_scores)
/path/to/my/venv/lib64/python3.9/site-packages/sklearn/cross_decomposition/_pls.py:272: RuntimeWarning: invalid value encountered in true_divide
y_loadings = np.dot(x_scores, Yk) / np.dot(x_scores, x_scores)
Traceback (most recent call last):
File "/path/to/my/venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-d3dc977168f5>", line 1, in <module>
model.fit(x, y)
File "/path/to/my/venv/lib64/python3.9/site-packages/sklearn/cross_decomposition/_pls.py", line 243, in fit
_get_first_singular_vectors_power_method(
File "/path/to/my/venv/lib64/python3.9/site-packages/sklearn/cross_decomposition/_pls.py", line 37, in _get_first_singular_vectors_power_method
y_score = next(col for col in Y.T if np.any(np.abs(col) > eps))
StopIteration
Versions
System:
python: 3.9.2 (default, Feb 20 2021, 00:00:00) [GCC 10.2.1 20201125 (Red Hat 10.2.1-9)]
executable: /path/to/my/venv/bin/python
machine: Linux-5.10.22-200.fc33.x86_64-x86_64-with-glibc2.32
Python dependencies:
pip: 20.2.2
setuptools: 49.6.0
sklearn: 0.24.1
numpy: 1.20.2
scipy: 1.6.1
Cython: None
pandas: 1.2.3
matplotlib: 3.4.1
joblib: 1.0.1
threadpoolctl: 2.1.0
Built with OpenMP: True
Metadata
Metadata
Assignees
Labels
No labels