亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為每個分類器繪制圖

為每個分類器繪制圖

千萬里不及你 2021-04-08 18:15:32
這是我的kfolds代碼kf = KFold(class_label.shape[0], n_folds=5, shuffle=True). for train_index, test_index in kf:.print("Train:", train_index, "Validation:",test_index). X_train, X_test = np.array(x)[train_index], np.array(x)[test_index]. y_train, y_test = np.array(class_label)[train_index], np.array(class_label)[test_index]情節應該看起來像這樣,但有10條線我想為每一折畫一條線,所以總共應該有十條線:test_score = []. train_score = []. for depth in range(20):.     clf = DecisionTreeClassifier(max_depth = depth + 1).     clf.fit(X_train,y_train).     train_score.append(clf.score(X_train,y_train)).     test_score.append(clf.score(X_test,y_test)). plt.figure(figsize = (8,8)). plt.plot(range(20),train_score). plt.plot(range(20), test_score). plt.xlabel('Tree Depth'). plt.ylabel('Accuracy'). plt.legend(['Training set','Test set']). 
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 170 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號