<jupyter_start><jupyter_text>多分类问题中的混淆矩阵<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets

digits = datasets.load_digits()
X = digits.data
y = digits.target.copy()

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.8, random_state=500)
from sklearn.linear_model import LogisticRegression

log_reg = LogisticRegression()
log_reg.fit(X_train, y_train)
log_reg.score(X_test, y_test)
y_predict = log_reg.predict(X_test)
from sklearn.metrics import precision_score

precision_score(y_test, y_predict, average='micro')
from sklearn.metrics import confusion_matrix

confusion_matrix(y_test, y_predict)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0846774193548387, 'fraction_numerical': 0.006720430107526882, 'mean_word_length': 8.085365853658537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '278431', 'license': 'MIT', 'n_tokens_mistral': 282, 'n_tokens_neox': 277, 'n_words': 56, 'path': '08Classification-Performance-Measures/05Confusion-Matrix-in-Multiple-Classification.ipynb', 'repo_name': 'ovtenng/ML-Algorithms-Action', 'size': '744'}