classification_report的格式
引用:sklearn.metrics.classification_report模块使用与指标分析(生成混淆矩阵评价分类指标)
在使用autoclassfication后获取其中的precision recall f1-score 值
def auto_sklearn_classification(X_train, X_test, y_train, y_test): cls = autosklearn.classification.AutoSklearnClassifier(time_left_for_this_task=300, per_run_time_limit=90, ml_memory_limit=10000) cls.fit(X_train, y_train) predictions = cls.predict(X_test) report = [] report_str = classification_report(y_test, predictions) for row in report_str.split("n"): parsed_row = [x for x in row.split(" ") if len(x) > 0] if len(parsed_row) > 0: report.append(parsed_row) # save accuracy, precision, recall, F1-Score to dictionary accuracy = accuracy_score(predictions,y_test) precision = float(report[-1][1])#最后一行第二列的值 recall = float(report[-1][2]) f1_score = float(report[-1][3]) return accuracy, precision, recall, f1_score
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)