мне нужно, чтобы вывод отображался в классификационной матрице, но я получаю строку в качестве вывода
from pyod.models.xgbod import XGBClassifier
clf = XGBClassifier(max_depth=15, min_child_weight=4, gamma=0.3,
colsample_bytree=0.4) # max_depth = 15, min_child_weight =4
clf.fit(x_train[:, np.newaxis], y_train)
y_pred1 = clf.predict(x_test[:, np.newaxis])
y_prob1 = clf.predict_proba(x_test[:, np.newaxis])
n_errors1 = (y_pred1 != y_test).sum()
print('')
print('XG boost no of Errors :{}'.format(n_errors1))
print('Accuracy Score: ', accuracy_score(y_test, y_pred1))
print('Classification report :')
print(classification_report(y_test, y_pred1))
av = accuracy_score(y_test, y_pred1)
cv = classification_report(y_test, y_pred1)
f1_score_xgb = f1_score(y_test, y_pred1, average='weighted')
print(f1_score_xgb)
return render_template('classification_report.html',cv = cv,f1_score =f1_score_xgb)
вывод:
XGBOOST :: отчет о классификации и оценка точности: отзыв точности f1поддержка 0 0,92 1,00 0,96 4073 1 0,90 0,23 0,36 466 микро-ср 0,92 0,92 0,92 4539 макро-ср 0,91 0,61 0,66 4539 средневзвешенное значение 0,92 0,92 0,89 4539
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>XG_BOOST Accuracy & C_report</title></head>
<body><h1> XGBOOST::</h1>
<p> classification report and accuracy score :{{cv}} </p>
<p> f1 score {{f1_score}}</p>
<p>print(cv)</p></body>
</html>