Pythonの概要:RuntimeError:matplotlibは入力としてジェネレーターをサポートしていません



Python Summary Runtimeerror



例:

ソース:stackoverflow: 質問



githubでサンプルを実行すると、 https://github.com/vsmolyakov/experiments_with_python/blob/master/chp01/ensemble_methods.ipynb

コード検出、Python3.xバージョンを使用したエラー。



plt.figure() (_, caps, _) = plt.errorbar(num_est, bg_clf_cv_mean, yerr=bg_clf_cv_std, c='blue', fmt='-o', capsize=5) for cap in caps: cap.set_markeredgewidth(1) plt.ylabel('Accuracy') plt.xlabel('Ensemble Size') plt.title('Bagging Tree Ensemble') plt.show()

実際、この場合、線がありますnum_est map =(int、np.linspace(1,100,20))Pythonバージョン2.7で作成されたこれはリストであり、Python3.xで作成されたものはジェネレーターであり、すべての推奨事項が置き換えられます。

num_est = np.linspace(1,100,20).astype(int)