0

I am using the recursive feature ranking function i scikit-learn (http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.RFECV.html#sklearn.feature_selection.RFECV). However, I would like use a LDA classifier as the estimator. I have this code:

X, y = make_friedman1(n_samples=50, n_features=10, random_state=0)
estimator = LDA()
#selector = RFE(estimator,5,step = 1)
selector = RFECV(estimator, cv = 5,step = 1)
selector=selector.fit(X,y)
print selector.support_
print selector.ranking_

When I execute this code, I am getting an error. If I execute the same code with RFE, it is ok. Or if I use the SVR classifier, it works ok. My question is if I am getting a classifier when I call the method LDA().The RFECV will use the classifier in the "estimator" to rank the features. What is the problem with LDA?

Kara
  • 6,115
  • 16
  • 50
  • 57
andreSmol
  • 1,028
  • 2
  • 18
  • 30

1 Answers1

1

From the docs:

sklearn.datasets.make_friedman1: Generate the “Friedman #1” regression problem

(emphasis added)

You can't sensibly use a classifier on a regression problem. The reason why SVR works is that isn't a classifier learner, but a regression learner.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836