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

Fixing 1D array deprecation warnings for model_params property #325

Closed
desilinguist opened this issue Jul 24, 2016 · 1 comment
Closed
Assignees
Milestone

Comments

@desilinguist
Copy link
Member

desilinguist commented Jul 24, 2016

Currently, in model_params we are using the following to get the coefficients for the selected features for a linear model:

coef = self.feat_selector.inverse_transform(coef)[0]

This sometimes raises DeprecationWarnings of the following kind:

/Users/nmadnani/anaconda/envs/rsmtool/lib/python3.4/site-packages/sklearn/utils/validation.py:386: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.

This happens because the inverse_transform() method of the feature selector requires a 2D array of shape [n_samples, n_features]. So, to get around these warnings we should simply change the SKLL code to be:

coef = coef.reshape(1, -1)
coef = self.feat_selector.inverse_transform(coef)[0]
@desilinguist
Copy link
Member Author

Addressed by #329.

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

1 participant