avidale / constrained-linear-regression

22 stars 5 forks source link

AttributeError: 'MatrixConstrainedLinearRegression' object has no attribute '_preprocess_data' #4

Closed ccomkhj closed 6 months ago

ccomkhj commented 1 year ago
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'MatrixConstrainedLinearRegression' object has no attribute '_preprocess_data'

Reproduce

from constrained_linear_regression import MatrixConstrainedLinearRegression
import numpy as np
from sklearn.datasets import make_regression

# Create a toy regression dataset
X, y = make_regression(n_samples=100, n_features=4)

# Create a constraint matrix and vector
# Here as an example, we give A as an identity matrix and B as ones,
# meaning we want all coefficients to be less than or equal to 1.
A = np.eye(X.shape[1])
B = np.ones(X.shape[1])

# Create and fit the model
model = MatrixConstrainedLinearRegression(A=A, B=B)
model.fit(X, y)
avidale commented 1 year ago

Sorry, but I cannot reproduce this issue. Which versions of constrained-linear-regression and scikit-learn packages are you using?

ccomkhj commented 1 year ago

@avidale Here's full lines for reproducing the error.

conda create -n test python=3.10
conda activate test
pip install constrained-linear-regression
from constrained_linear_regression import MatrixConstrainedLinearRegression
import numpy as np
from sklearn.datasets import make_regression

# Create a toy regression dataset
X, y = make_regression(n_samples=100, n_features=4)

# Create a constraint matrix and vector
# Here as an example, we give A as an identity matrix and B as ones,
# meaning we want all coefficients to be less than or equal to 1.
A = np.eye(X.shape[1])
B = np.ones(X.shape[1])

# Create and fit the model
model = MatrixConstrainedLinearRegression(A=A, B=B)
model.fit(X, y)

Error happens

AttributeError: 'MatrixConstrainedLinearRegression' object has no attribute '_preprocess_data'

pip list

asttokens                     2.2.1
autopep8                      2.0.1
backcall                      0.2.0
black                         22.10.0
comm                          0.1.2
**constrained-linear-regression 0.0.4**
debugpy                       1.6.5
decorator                     5.1.1
entrypoints                   0.4
executing                     1.2.0
ipykernel                     6.20.2
ipython                       8.8.0
jedi                          0.18.2
joblib                        1.3.2
jupyter_client                7.4.9
jupyter_core                  5.1.3
matplotlib-inline             0.1.6
mypy-extensions               0.4.3
nest-asyncio                  1.5.6
numpy                         1.26.1
parso                         0.8.3
pathspec                      0.10.1
pickleshare                   0.7.5
pip                           23.3
platformdirs                  2.5.2
prompt-toolkit                3.0.36
psutil                        5.9.4
pure-eval                     0.2.2
pycodestyle                   2.10.0
python-dateutil               2.8.2
pyzmq                         25.0.0
**scikit-learn                  1.1.0**
scipy                         1.11.3
setuptools                    65.6.3
stack-data                    0.6.2
threadpoolctl                 3.2.0
tomli                         2.0.1
traitlets                     5.8.1
wcwidth                       0.2.6
wheel                         0.41.2