8000 Larsmans sparse nmf compat for numpy 1.5 by ogrisel · Pull Request #1 · larsmans/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Larsmans sparse nmf compat for numpy 1.5 #1

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

Closed
wants to merge 13 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed issue scikit-learn#378 on the RFE module
  • Loading branch information
glouppe committed Oct 3, 2011
commit c0881f746c74358bb6d03843529b513df251f68f
18 changes: 9 additions & 9 deletions sklearn/feature_selection/rfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ class RFE(BaseEstimator):
----------
estimator : object
A supervised learning estimator with a `fit` method that updates a
`coef_` attribute that holds the fitted parameters. The first
dimension of the `coef_` array must be equal to the number of features
of the input dataset of the estimator. Important features must
correspond to high absolute values in the `coef_` array.
`coef_` attribute that holds the fitted parameters. Important features
must correspond to high absolute values in the `coef_` array.

For instance, this is the case for most supervised learning
algorithms such as Support Vector Classifiers and Generalized
Expand Down Expand Up @@ -121,7 +119,11 @@ def fit(self, X, y):
# Rank the remaining features
estimator = clone(self.estimator)
estimator.fit(X[:, features], y)
ranks = np.argsort(np.sum(estimator.coef_ ** 2, axis=0))

if estimator.coef_.ndim > 1:
ranks = np.argsort(np.sum(estimator.coef_ ** 2, axis=0))
else:
ranks = np.argsort(estimator.coef_ ** 2)

# Eliminate the worse features
threshold = min(step, np.sum(support_) - self.n_features_to_select)
Expand Down Expand Up @@ -191,10 +193,8 @@ class RFECV(RFE):
----------
estimator : object
A supervised learning estimator with a `fit` method that updates a
`coef_` attribute that holds the fitted parameters. The first
dimension of the `coef_` array must be equal to the number of features
of the input dataset of the estimator. Important features must
correspond to high absolute values in the `coef_` array.
`coef_` attribute that holds the fitted parameters. Important features
must correspond to high absolute values in the `coef_` array.

For instance, this is the case for most supervised learning
algorithms such as Support Vector Classifiers and Generalized
Expand Down
0