Cross Validation
-
Cross validation에서 ROC AUC 구하기라이브러리/Scikit-learn 2021. 2. 14. 20:44
StratifiedKFold을 통해 cross validation할 데이터 생성 from sklearn.linear_model import LogisticRegression from sklearn.model_selection import cross_val_score, StratifiedKFold cv = StratifiedKFold(n_splits=5,shuffle=False) 각 cv별 fpr(False Positive Rate), tpr(True Positive Rate) 및 auc(Area under the ROC Curve) 계산 및 평균 계산 logit = LogisticRegression(fit_intercept=True) tprs = [] aucs = [] mean_fpr_lr = np.li..
-
Cross validation에서 Confusion Matrix을 Metric으로 사용하기라이브러리/Scikit-learn 2021. 2. 14. 20:24
여기서 clf는 model, x는 학습 데이터, y는 x의 label 대신 from sklearn.model_selection import cross_val_predict from sklearn.metrics import confusion_matrix y_pred = cross_val_predict(clf, X, y, cv=5) conf_mat = confusion_matrix(y, y_pred) 이 값을 시각화 하는 방법은 다음과 같다. from sklearn.model_selection import cross_val_predict from sklearn.metrics import confusion_matrix from sklearn.metrics import ConfusionMatrixDisplay ..