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

SlimRegressor error #25

Closed
ukamath opened this issue Jan 5, 2021 · 1 comment
Closed

SlimRegressor error #25

ukamath opened this issue Jan 5, 2021 · 1 comment

Comments

@ukamath
Copy link

ukamath commented Jan 5, 2021

When I run SlimRegressor on a regression data
from imodels import SLIMRegressor
model = SLIMRegressor()
for lambda_reg in [0, 1e-2, 5e-2, 1e-1, 1, 2]:
model.fit(X_train, y_train, lambda_reg)
mse = np.mean(np.square(y_train - model.predict(X_train)))
print(f'lambda: {lambda_reg}\tmse: {mse: 0.2f}\tweights: {model.model.coef_}')

I get

SolverError: Either candidate conic solvers (['GLPK_MI']) do not support the cones output by the problem (SOC, NonNeg), or there are not enough constraints in the problem.

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
in
2 model = SLIMRegressor()
3 for lambda_reg in [0, 1e-2, 5e-2, 1e-1, 1, 2]:
----> 4 model.fit(X_train, y_train, lambda_reg)
5 mse = np.mean(np.square(y_train - model.predict(X_train)))
6 print(f'lambda: {lambda_reg}\tmse: {mse: 0.2f}\tweights: {model.model.coef_}')

~/opt/anaconda3/lib/python3.7/site-packages/imodels/algebraic/slim.py in fit(self, X, y, lambda_reg, sample_weight)
58 except:
59 m = Lasso(alpha=lambda_reg)
---> 60 m.fit(X, y, sample_weight=sample_weight)
61 self.model.coef_ = np.round(m.coef_).astype(np.int)
62 self.model.intercept_ = m.intercept_

TypeError: fit() got an unexpected keyword argument 'sample_weight'

@csinva
Copy link
Owner

csinva commented Jan 5, 2021

Thanks for your interest and pointing this out!

The issue here is that your scikit-learn version is < 0.23. To fix this, you'll have to upgrade it to 0.23 or higher. We'll add this to the requirements!

@csinva csinva closed this as completed Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants