<p dir="auto">So my box in uni got upgraded and now I have this test failure:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="======================================================================
FAIL: sklearn.manifold.tests.test_locally_linear.test_lle_simple_grid
----------------------------------------------------------------------
Traceback (most recent call last):
  File &quot;/usr/lib/python2.7/dist-packages/nose/case.py&quot;, line 197, in runTest
    self.test(*self.arg)
  File &quot;/home/local/lamueller/checkout/scikit-learn/sklearn/manifold/tests/test_locally_linear.py&quot;, line 68, in test_lle_simple_grid
    assert_less(np.linalg.norm(X_reembedded - clf.embedding_), tol)
AssertionError: 0.12820616722921346 not less than 0.1
    &quot;&quot;&quot;Fail immediately, with the given message.&quot;&quot;&quot;
&gt;&gt;  raise self.failureException('0.12820616722921346 not less than 0.1')"><pre class="notranslate"><code class="notranslate">======================================================================
FAIL: sklearn.manifold.tests.test_locally_linear.test_lle_simple_grid
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/local/lamueller/checkout/scikit-learn/sklearn/manifold/tests/test_locally_linear.py", line 68, in test_lle_simple_grid
    assert_less(np.linalg.norm(X_reembedded - clf.embedding_), tol)
AssertionError: 0.12820616722921346 not less than 0.1
    """Fail immediately, with the given message."""
&gt;&gt;  raise self.failureException('0.12820616722921346 not less than 0.1')
</code></pre></div>
<p dir="auto">scipy 0.10.1, 32bit.</p>
<h4 dir="auto">Describe the issue linked to the documentation</h4>
<p dir="auto">when I look at the example given <a href="https://scikit-learn.org/stable/auto_examples/release_highlights/plot_release_highlights_0_22_0.html#permutation-based-feature-importance" rel="nofollow">here</a>, I got confused why the feature names are not sorted with respect to importance.</p>
<h4 dir="auto">Suggest a potential alternative/fix</h4>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="X, y = make_classification(random_state=0, n_features=5,
                           n_informative=3)
rf = RandomForestClassifier(random_state=0).fit(X, y)
result = permutation_importance(rf, X, y, n_repeats=10, random_state=0,
                                n_jobs=-1)

feature_names = np.array([f'x_{i}' for i in range(X.shape[1])])

fig, ax = plt.subplots()
sorted_idx = result.importances_mean.argsort()
ax.boxplot(result.importances[sorted_idx].T,
           vert=False, labels=feature_names[sorted_idx])
ax.set_title(&quot;Permutation Importance of each feature&quot;)
ax.set_ylabel(&quot;Features&quot;)
fig.tight_layout()
plt.show()"><pre class="notranslate"><code class="notranslate">X, y = make_classification(random_state=0, n_features=5,
                           n_informative=3)
rf = RandomForestClassifier(random_state=0).fit(X, y)
result = permutation_importance(rf, X, y, n_repeats=10, random_state=0,
                                n_jobs=-1)

feature_names = np.array([f'x_{i}' for i in range(X.shape[1])])

fig, ax = plt.subplots()
sorted_idx = result.importances_mean.argsort()
ax.boxplot(result.importances[sorted_idx].T,
           vert=False, labels=feature_names[sorted_idx])
ax.set_title("Permutation Importance of each feature")
ax.set_ylabel("Features")
fig.tight_layout()
plt.show()
</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20812407/82727658-85022c00-9d09-11ea-82be-2b864c5c6735.png"><img width="492" alt="image" src="https://user-images.githubusercontent.com/20812407/82727658-85022c00-9d09-11ea-82be-2b864c5c6735.png" style="max-width: 100%;"></a></p>
<p dir="auto">Also, for clarity may be we can set  <code class="notranslate">n_redundant=0</code>, hence emphasising that <code class="notranslate">permutation_importance</code> identifies the 3 informative features precisely.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="X, y = make_classification(random_state=0, n_features=5,
                           n_informative=3, n_redundant=0)
rf = RandomForestClassifier(random_state=0).fit(X, y)
result = permutation_importance(rf, X, y, n_repeats=10, random_state=0,
                                n_jobs=-1)

feature_names = np.array([f'x_{i}' for i in range(X.shape[1])])

fig, ax = plt.subplots()
sorted_idx = result.importances_mean.argsort()
ax.boxplot(result.importances[sorted_idx].T,
           vert=False, labels=feature_names[sorted_idx])
ax.set_title(&quot;Permutation Importance of each feature&quot;)
ax.set_ylabel(&quot;Features&quot;)
fig.tight_layout()
plt.show()"><pre class="notranslate"><code class="notranslate">X, y = make_classification(random_state=0, n_features=5,
                           n_informative=3, n_redundant=0)
rf = RandomForestClassifier(random_state=0).fit(X, y)
result = permutation_importance(rf, X, y, n_repeats=10, random_state=0,
                                n_jobs=-1)

feature_names = np.array([f'x_{i}' for i in range(X.shape[1])])

fig, ax = plt.subplots()
sorted_idx = result.importances_mean.argsort()
ax.boxplot(result.importances[sorted_idx].T,
           vert=False, labels=feature_names[sorted_idx])
ax.set_title("Permutation Importance of each feature")
ax.set_ylabel("Features")
fig.tight_layout()
plt.show()
</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20812407/82727670-951a0b80-9d09-11ea-9c25-ea9eaeb94347.png"><img width="492" alt="image" src="https://user-images.githubusercontent.com/20812407/82727670-951a0b80-9d09-11ea-9c25-ea9eaeb94347.png" style="max-width: 100%;"></a></p>