あるデータに関して、ランダムフォレストによってカテゴリ分けを予測する中で
python
1#4分類した場合#new_data 2import pandas as pd 3df=pd.read_csv("/Users/sakaikouki/Desktop/元データ詳細のコピー.csv") 4from sklearn.model_selection import train_test_split 5X=df.drop("con_rate",axis=1) 6y=df.con_rate 7(train_X, test_X ,train_y, test_y) = train_test_split(X, y, test_size = 0.3, random_state = 0) 8#ランダムフォレスト 9from sklearn.ensemble import RandomForestClassifier 10clf = RandomForestClassifier(random_state=0,n_estimators=50) 11clf = clf.fit(train_X, train_y) 12pred = clf.predict(test_X) 13fpr, tpr, thresholds = roc_curve(test_y, pred, pos_label=1) 14auc(fpr, tpr) 15accuracy_score(pred, test_y)
と打つとエラーコードで
python
1--------------------------------------------------------------------------- 2NameError Traceback (most recent call last) 3<ipython-input-4-d608726e98d7> in <module>() 4 11 clf = clf.fit(train_X, train_y) 5 12 pred = clf.predict(test_X) 6---> 13 fpr, tpr, thresholds = roc_curve(test_y, pred, pos_label=1) 7 14 auc(fpr, tpr) 8 15 accuracy_score(pred, test_y) 9 10NameError: name 'roc_curve' is not defined 11
とでます。この問題はどう解決すればいいのでしょうか?
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/12 06:06