amueller / introduction_to_ml_with_python

Notebooks and code for the book "Introduction to Machine Learning with Python"
7.45k stars 4.57k forks source link

Bug in plot_cross_val_selection method #161

Closed karitonov closed 2 years ago

karitonov commented 2 years ago

plot_grid_search.py

line 20: results = pd.DataFrame(grid_search.cvresults)[15:] line 37-38: plt.xticks(range(len(results)), [str(x).strip("{}").replace("'", "") for x in grid_search.cvresults['params']],

In line 37-38, an error occurs because the length of results and grid_search.cvresults['params']] does not match.

Therefore, the line number 20 is corrected as follows.

results = pd.DataFrame(grid_search.cv_results_)#[15:] comment out

And then, add the following rows to some suitable places (For example, after the 41st line.).

plt.xlim(14.5, 36)

Thank you for your cooperation.

wanghedy commented 2 years ago

您的邮件已收到,我将会尽快处理,谢谢。王宇凝

karitonov commented 2 years ago

https://github.com/amueller/introduction_to_ml_with_python/issues/156#issue-1125129453

This issue is almost the same as above.

karitonov commented 2 years ago

https://github.com/amueller/introduction_to_ml_with_python/issues/156#issue-1125129453

The above method is better, so I will withdraw.