Pages

Topics

Tools

↑↓navigate↵openescclose

Python guides

Every published Python guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Python guides

A visual comparison of Python pickle and joblib serialization paths, showing a numpy array being stored as a separate memory-mapped file in joblib.
Python

python joblib vs pickle: Choosing the Right Serializer

Compare Python's pickle and joblib for object serialization. Learn how joblib handles large NumPy arrays, compression, memory mapping, and when to choose each serializer.

joblibpickleserializationnumpy
Diagram showing a Python loop being split into parallel tasks across multiple processes using joblib.
Python

Using joblib Parallel and delayed with multiprocessing

Learn how to parallelize Python loops with joblib's Parallel and delayed, how they relate to multiprocessing, and how to avoid common pitfalls.

joblibparallel processingmultiprocessingPython performance
Illustration of saving and loading a scikit-learn model with joblib in Python
Python

Saving and Loading Scikit-Learn Models With Joblib in Python

Learn how to save and load scikit-learn models with joblib, including dump/load syntax, compression, version compatibility, and when joblib is a better choice than pickle.

joblibscikit-learnmodel persistenceserialization
Illustration of a random seed controlling reproducible results in scikit-learn experiments
Python

Python sklearn random_state Reproducibility

Learn how random_state in scikit-learn controls randomness and how to set it for data splits, estimators, pipelines, and cross-validation to make experiments reproducible.

scikit-learnrandom_statereproducibilitydeterministic
Illustration of a balanced scale with many small shapes on one side and one large shape on the other, representing imbalanced classes, with a subtle Python code background.
Python

Python sklearn Class Imbalance Handling: Practical Strategies

Practical techniques for handling imbalanced datasets with Python and sklearn: class_weight, resampling with imbalanced-learn, SMOTE, and evaluation metrics.

class imbalancesklearnimbalanced-learnSMOTE
A diagram showing a trained scikit-learn model being serialized to a file with joblib and restored for prediction.
Python

Save and Load sklearn Models with Joblib

python sklearn save and load models with joblib: Save trained scikit-learn models with joblib.dump and restore them with joblib.load, including compression, version co...

scikit-learnjoblibmodel persistencePython
A visual representation of regression metrics MSE, RMSE, and R² in scikit-learn, showing predicted vs actual values.
Python

MSE, RMSE, and R²: Regression Metrics with scikit-learn in Python

Learn how to compute and interpret MSE, RMSE, and R² for regression models using scikit-learn. Includes code examples and practical guidance for choosing the right metric.

scikit-learnregression metricsMSERMSE
A ROC curve with the area under the curve highlighted, next to a Python code snippet showing predict_proba usage.
Python

Using predict_proba for ROC AUC in Python sklearn

python sklearn roc auc and predict_proba: Learn why roc_auc_score needs predict_proba instead of predict, how to use it for binary and multiclass models, and common pi...

ROC AUCscikit-learnpredict_probamodel evaluation
Illustration of a confusion matrix grid with precision, recall, and F1 metric labels in a scikit-learn classification evaluation workflow.
Python

sklearn Classification Metrics: Confusion Matrix to F1

python sklearn classification metrics confusion matrix precision recall f1: Compute and interpret sklearn classification metrics: confusion matrix, precision, recall,...

scikit-learnclassification metricsconfusion matrixprecision
A visual comparison of an exhaustive grid search and a random sampling search over a two-dimensional hyperparameter space in scikit-learn.
Python

GridSearchCV vs RandomizedSearchCV in Scikit-Learn: How to Choose

Compare GridSearchCV and RandomizedSearchCV in scikit-learn: how each searches the parameter space, runtime tradeoffs, and when to use one or the other.

scikit-learnhyperparameter tuningGridSearchCVRandomizedSearchCV