混同行列を読み解く
真陽性、偽陽性、真陰性、偽陰性
「混同行列を読み解く」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはData Science Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Data Science Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Beyond a Single Number
For classifiers, one accuracy score hides too much. The confusion matrix lays out exactly which predictions were right and which were wrong. 🧩
A Simple Grid
The matrix is a small grid: rows are the true classes, columns are the predicted ones. Each cell counts how often that pairing happened.
from sklearn.metrics import confusion_matrix
confusion_matrix(y_true, y_pred)True Positives
A true positive is when the model says yes and the answer really is yes. These are the wins you want to maximize.
True Negatives
A true negative is when the model says no and the truth is also no. The model correctly left this case alone.
False Positives
A false positive is a false alarm: the model predicted yes, but the truth was no. Think of flagging a healthy patient as sick.
False Negatives
A false negative is a miss: the model said no while the truth was yes. Picture letting a real fraud slip through unnoticed.
Two Kinds of Mistakes
Notice the two error types differ in cost. A false positive and a false negative are rarely equal, so the matrix keeps them separate.
Where Accuracy Lives
Accuracy is just the correct cells over the total. It is the diagonal divided by everything, which is why it can mask rare errors.
accuracy = (TP + TN) / (TP + TN + FP + FN)Read the Off-Diagonal
The most useful cells sit off the diagonal: they show where the model confuses one class for another, pointing to its weak spots.
See It as a Heatmap
For many classes, plot the matrix as a heatmap. Bright off-diagonal squares instantly reveal which labels get mixed up most.
from sklearn.metrics import ConfusionMatrixDisplay
ConfusionMatrixDisplay.from_predictions(y_true, y_pred)Your Metric Foundation
Almost every classification metric is built from these four counts. Master the confusion matrix and the rest follow naturally.
Quick Check
Let's make sure each cell of the matrix is crystal clear.
Recap
The confusion matrix splits results into true and false, positive and negative. Those four counts power every classification metric. 🎯
よくある質問
「混同行列を読み解く」レッスンは無料ですか?
はい。「混同行列を読み解く」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。
「混同行列を読み解く」で何を学びますか?
真陽性、偽陽性、真陰性、偽陰性 ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Data Science Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「混同行列を読み解く」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このData Science Academyレッスンでコードを書いて実行できますか?
はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。