KNN with RFECV returns: "The classifier does not expose "coef_" or "feature_importances_" attributes"
<p>I am trying to apply RFECV on KNeighborsClassifier to eliminate insignificant features. In order to make the issue repeatable, here is an example with iris data:</p>

<pre><code>from sklearn.datasets import load_iris
from sklearn.feature_selection import RFECV
from sklearn.neighbors import KNeighborsClassifier
iris = load_iris()
y = iris.target
X = iris.data
estimator = KNeighborsClassifier()
selector = RFECV(estimator, step=1, cv=5)
selector = selector.fit(X, y)
</code></pre>

<p>which results in the following error massage:</p>

<pre><code>---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-27-19f0f2f0f0e7&gt; in &lt;module&gt;()
      7 estimator = KNeighborsClassifier()
      8 selector = RFECV(estimator, step=1, cv=5)
----&gt; 9 selector.fit(X, y)

C:...\Anaconda3\lib\site-packages\sklearn\feature_selection\rfe.py in fit(self, X, y)
    422                       verbose=self.verbose - 1)
    423 
--&gt; 424             rfe._fit(X_train, y_train, lambda estimator, features:
    425                      _score(estimator, X_test[:, features], y_test, scorer))
    426             scores.append(np.array(rfe.scores_[::-1]).reshape(1, -1))

C:...\Anaconda3\lib\site-packages\sklearn\feature_selection\rfe.py in _fit(self, X, y, step_score)
    180                 coefs = estimator.feature_importances_
    181             else:
--&gt; 182                 raise RuntimeError('The classifier does not expose '
    183                                    '"coef_" or "feature_importances_" '
    184                                    'attributes')

RuntimeError: The classifier does not expose "coef_" or "feature_importances_" attributes
</code></pre>

<p>If I change the classifier to a SVC as:</p>

<pre><code>from sklearn.datasets import load_iris
from sklearn.feature_selection import RFECV
from sklearn.svm import SVC
iris = load_iris()
y = iris.target
X = iris.data
estimator = SVC(kernel="linear")
selector = RFECV(estimator, step=1, cv=5)
selector = selector.fit(X, y)
</code></pre>

<p>it would work fine. Any suggestions on how to address the issue? </p>

<p><strong>NOTE:</strong> I updated Anaconda yesterday which also updated the sklearn.</p>