Lendo a matriz de confusão
Veja exatamente onde o modelo erra.
Lendo a matriz de confusão é uma aula grátis de NLP Academy no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de NLP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de NLP Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
The Whole Picture
The confusion matrix is a small table showing every prediction sorted by what was true and what you guessed. It reveals exactly where errors live.
Rows and Columns
Rows are the true labels and columns are the predicted ones. Each cell counts how many examples fell into that true-versus-predicted combination.
The Four Cells
For two classes you get four counts: true positives, true negatives, and the two error types. Every metric you know is built from these.
True Positive
A true positive is a real positive you correctly flagged, like real spam sent straight to the spam folder. A clean win.
True Negative
A true negative is a real negative you correctly left alone, like a normal email that stays safely in the inbox.
False Positive
A false positive is a false alarm: you flagged something that was actually negative, like a real email wrongly marked as spam.
False Negative
A false negative is a miss: a real positive you let slip through, like spam that lands in the inbox unflagged.
The Diagonal Tells All
Correct predictions sit on the diagonal. A strong model concentrates counts there and leaves the off-diagonal cells nearly empty.
Build It in Python
scikit-learn assembles the matrix from your true and predicted labels in a single call.
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_true, y_pred)Make It Readable
A plotted matrix makes errors jump out, so you instantly see which class gets confused for which.
from sklearn.metrics import ConfusionMatrixDisplay
ConfusionMatrixDisplay(cm).plot()Spotting the Weak Spot
Read off-diagonal cells to find the model blind spot. A large false-negative count, for example, warns you that real positives are being missed.
Quick Check
Name the error type from the description.
Recap
The confusion matrix splits results into four cells. The diagonal holds wins; off-diagonal cells expose exactly where your model errs. 🔍
Perguntas Frequentes
A aula “Lendo a matriz de confusão” é grátis?
Sim — o texto completo de “Lendo a matriz de confusão” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de NLP Academy, atualize para CoddyKit PRO. O curso de NLP Academy inclui 4 aulas no total.
O que vou aprender em “Lendo a matriz de confusão”?
Veja exatamente onde o modelo erra. Você pratica NLP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar NLP Academy?
Nenhuma experiência prévia é necessária. NLP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.
Quanto tempo leva a aula “Lendo a matriz de confusão”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de NLP Academy?
Sim. Cada aula de NLP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Por que a acurácia pode enganar
- Precisão, revocação e F1
- Lendo a matriz de confusão
- Validação cruzada do jeito certo