標準偏差を計算して、交差検証の結果から評価指標のばらつきを確認するコードに組み込みたい

2024年6月17日

標準偏差を計算して、交差検証の結果から評価指標のばらつきを確認するためのコードを以下に示します。

python
import numpy as np

# 交差検証の結果からPrecision、Recall、F1-scoreの標準偏差を計算
precision_std = np.std(cv_results['test_precision'])
recall_std = np.std(cv_results['test_recall'])
f1_score_std = np.std(cv_results['test_f1_score'])

# 結果の表示
print("Precision Standard Deviation:", precision_std)
print("Recall Standard Deviation:", recall_std)
print("F1-score Standard Deviation:", f1_score_std)

このコードは、交差検証の結果からPrecision、Recall、F1-scoreの標準偏差を計算し、それらを表示します。標準偏差が小さいほど、各評価指標のばらつきが小さいことを示し、モデルの性能が安定していることを意味します。

未分類

Posted by ぼっち