0Pricing
Data Science Academy · Aula

ROC, AUC e limiares

Avaliando a qualidade da ordenação em diferentes pontos de corte.

ROC, AUC e limiares é uma aula grátis de Data Science Academy no CoddyKit. Esta é a aula 4 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 Data Science Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Data Science Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Models Output Probabilities

Most classifiers do not just say yes or no. They give a probability, like 0.73, and you decide where to draw the line. 🎚️

probs = model.predict_proba(X)[:, 1]

The Decision Threshold

A threshold turns a probability into a label. Above it means positive, below means negative. The default 0.5 is just one choice.

y_pred = probs >= 0.5

Moving the Line

Lower the threshold and you catch more positives but raise false alarms. Raise it and you are stricter but miss more. Each setting trades off.

Two Rates to Track

As the threshold slides, watch the true positive rate against the false positive rate. Together they describe the model at every cutoff.

The ROC Curve

The ROC curve plots true positive rate versus false positive rate across all thresholds, showing the full trade-off in one picture.

from sklearn.metrics import roc_curve
fpr, tpr, thr = roc_curve(y_true, probs)

Reading the Shape

A curve that hugs the top-left corner is excellent: high catch rate with few false alarms. A diagonal line means random guessing.

Area Under the Curve

AUC squeezes the whole ROC curve into one number: the area beneath it. It summarizes performance across every threshold at once.

from sklearn.metrics import roc_auc_score
roc_auc_score(y_true, probs)

What AUC Means

AUC of 1.0 is perfect, 0.5 is coin-flip random. Read it as the chance the model ranks a true positive above a true negative.

Threshold-Free Comparison

Because AUC ignores any single cutoff, it is great for comparing models. The winner ranks positives ahead of negatives more often.

Then Pick a Threshold

AUC picks the model, but you still set the threshold for real use, tuning it to favor recall or precision as the problem demands.

When to Prefer PR Curves

On very imbalanced data, ROC can look rosy. A precision-recall curve often tells the harder truth about rare-class performance.

Quick Check

Let's confirm what AUC really tells you about a classifier.

Recap

The threshold turns probabilities into labels, the ROC curve shows every trade-off, and AUC scores the whole curve at once. 🎯

Perguntas Frequentes

A aula “ROC, AUC e limiares” é grátis?

Sim — o texto completo de “ROC, AUC e limiares” é 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 Data Science Academy, atualize para CoddyKit PRO. O curso de Data Science Academy inclui 4 aulas no total.

O que vou aprender em “ROC, AUC e limiares”?

Avaliando a qualidade da ordenação em diferentes pontos de corte. Você pratica Data Science 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 Data Science Academy?

Nenhuma experiência prévia é necessária. Data Science 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 4 de 4.

Quanto tempo leva a aula “ROC, AUC e limiares”?

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 Data Science Academy?

Sim. Cada aula de Data Science 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

  1. Métricas de regressão: MAE, MSE e R2
  2. Decodificando a matriz de confusão
  3. Precisão, revocação e F1
  4. ROC, AUC e limiares
← Voltar para Data Science Academy