Я пытался правильно построить матрицу путаницы, поэтому я следовал за более новой версией scikit-learn 0.22 во встроенной функции матрицы путаницы сюжета . Однако одно значение моего значения матрицы смешения - 153, но на графике матрицы смешения оно выглядит как 1,5e + 02: ![enter image description here](https://i.stack.imgur.com/57Io2.png)
Следуя документации scikit-learn , я заметил этот параметр с именем values_format
, но я не знаю, как управлять этим параметром, чтобы он мог подавить научную нотацию c. Мой код выглядит следующим образом.
from sklearn import svm, datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import plot_confusion_matrix
# import some data to play with
X = pd.read_csv("datasets/X.csv")
y = pd.read_csv("datasets/y.csv")
class_names = ['Not Fraud (positive)', 'Fraud (negative)']
# Split the data into a training set and a test set
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
# Run classifier, using a model that is too regularized (C too low) to see
# the impact on the results
logreg = LogisticRegression()
logreg.fit(X_train, y_train)
np.set_printoptions(precision=2)
# Plot non-normalized confusion matrix
titles_options = [("Confusion matrix, without normalization", None),
("Normalized confusion matrix", 'true')]
for title, normalize in titles_options:
disp = plot_confusion_matrix(logreg, X_test, y_test,
display_labels=class_names,
cmap=plt.cm.Greens,
normalize=normalize, values_format = '{:.5f}'.format)
disp.ax_.set_title(title)
print(title)
print(disp.confusion_matrix)
plt.show()