# Machine Learning Charts in Python: A Guide to Evaluating and Exploring Models

> A guide to the main machine learning charts in Python with scikit-learn: which plot to use to compare classifiers, check probabilities, explain predictions, choose k for K-means and reduce dimensions with PCA.

Source: https://www.pythoncharts.com/machine-learning/machine-learning-python-guide/ | Published: 2026-11-25 | Author: Alex Scott | Category: Machine Learning | Tags: machine learning, scikit-learn, model evaluation, classification, clustering, shap, guide

Most machine learning questions can be answered with one chart: scikit-learn's `RocCurveDisplay` and `PrecisionRecallDisplay` compare classifiers, `CalibrationDisplay` checks whether probabilities can be trusted, SHAP and permutation importance explain what a model uses, and `KMeans` with silhouette scores and `PCA` explore data without labels. This page maps each question to the tutorial that answers it, with runnable code and seeded sample data in every post.

![Grid of seven machine learning charts: ROC curve, precision-recall curve, calibration curve, SHAP beeswarm, feature importance, K-means elbow and silhouette, and a PCA biplot](https://www.pythoncharts.com/machine-learning/machine-learning-python-guide/images/ml-hub-montage.png)

## Which Chart Answers Which Question?

| Your question | Chart | Tutorial |
|---|---|---|
| Which classifier ranks cases better? | ROC curve and AUC | [ROC Curve and AUC](https://www.pythoncharts.com/machine-learning/roc-curve-auc-python/) |
| The positive class is rare. How do I compare models? | Precision-recall curve | [Precision-Recall Curve](https://www.pythoncharts.com/machine-learning/precision-recall-curve-python/) |
| Can I read the predicted probabilities as real chances? | Calibration curve, Brier score | [Calibration Curve](https://www.pythoncharts.com/machine-learning/calibration-curve-python/) |
| Is the model overfitting, and would more data help? | Learning curve, validation curve | [Learning and Validation Curves](https://www.pythoncharts.com/machine-learning/learning-curve-validation-curve-python/) |
| How does the prediction change as one feature changes? | Partial dependence and ICE | [Partial Dependence and ICE Plots](https://www.pythoncharts.com/machine-learning/partial-dependence-ice-plot-python/) |
| Is my regression model wrong in a systematic way? | Residual plot, Q-Q plot | [Residual Plot for Regression](https://www.pythoncharts.com/machine-learning/residual-plot-regression-python/) |
| What shape does my classifier's boundary have? | Decision boundary plot | [Decision Boundary Plot](https://www.pythoncharts.com/machine-learning/decision-boundary-plot-python/) |
| What rules did my decision tree learn? | plot_tree, export_text, pruning | [Plot a Decision Tree](https://www.pythoncharts.com/machine-learning/plot-decision-tree-python/) |
| Which features does the model rely on? | Impurity and permutation importance | [Feature Importance](https://www.pythoncharts.com/machine-learning/feature-importance-python/) |
| Why did the model predict this for this row? | SHAP beeswarm, bar, waterfall | [SHAP Plots](https://www.pythoncharts.com/machine-learning/shap-plots-python/) |
| How many clusters should I use? | Elbow plot and silhouette plot | [K-Means Elbow and Silhouette](https://www.pythoncharts.com/machine-learning/kmeans-elbow-silhouette-python/) |
| Can I summarize many correlated columns in two or three? | Scree plot, loadings, biplot | [PCA Explained Variance and Biplot](https://www.pythoncharts.com/machine-learning/pca-explained-variance-biplot-python/) |
| Can I see my high-dimensional data as clusters in 2D? | t-SNE and UMAP embedding plots | [t-SNE vs UMAP](https://www.pythoncharts.com/machine-learning/tsne-vs-umap-python/) |

## A Sensible Order for Evaluating a Classifier

1. **Rank first.** Plot a ROC curve and compute AUC to see whether the model separates the classes at all. If positives are rare, add a precision-recall curve, because AUC can look flattering when negatives dominate.
2. **Check the probabilities.** A model with a high AUC can still give bad probabilities. A calibration curve shows it, and `CalibratedClassifierCV` fixes it. This matters whenever the score feeds a decision such as a price, a threshold or an expected-value calculation. Calibration barely changes ranking metrics like AUC, so the two checks answer different questions.
3. **Explain it.** Permutation importance gives a quick global ranking of features. SHAP adds direction and per-row explanations.

## Charts for Data Without Labels

K-means and PCA need no target column. They are usually run together: scale the features, use PCA to see whether the data has a low-dimensional shape, then cluster and check the clusters with silhouette scores. Both posts show the effect of skipping `StandardScaler`. In the PCA post, one large-valued column took 93% of the variance when the data was not scaled.

## Which Tutorial Should I Start With?

| If you are... | Start with |
|---|---|
| New to model evaluation | ROC curve, then precision-recall |
| Shipping a model whose scores feed a decision | Calibration curve |
| Asked to explain a model to stakeholders | Feature importance, then SHAP |
| Exploring a new dataset | PCA, then K-means |

## Practical Tips

- Evaluate on held-out data. Every chart here is misleading when drawn from the training set.
- Fix the random seed so the charts are reproducible. All generator scripts in these posts use a seeded `np.random.default_rng`.
- Plot more than one metric. ROC, precision-recall and calibration each fail in a different way, and a model can pass one and fail another.

## Similar Topics

- [A/B Testing in Python: A Guide from Sample Size to Sequential Tests](https://www.pythoncharts.com/ab-testing/ab-testing-python-guide/)
- [Plotting a Correlation Matrix Heatmap with Annotations](https://www.pythoncharts.com/matplotlib/correlation-matrix-heatmap-annotations/)
