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 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
A diagram showing data splits for cross-validation with training and validation folds in a scikit-learn workflow.
Python

Python sklearn Cross Validation Explained

Use scikit-learn cross-validation to get reliable model performance estimates, choose the right strategy, and avoid data leakage with practical Python examples.

cross-validationscikit-learnmodel evaluationK-Fold
Diagram of a sklearn pipeline with a ColumnTransformer routing numeric and categorical columns into separate preprocessing branches before a final model step.
Python

Using scikit-learn Pipeline and ColumnTransformer

Learn how to combine scikit-learn Pipeline and ColumnTransformer into one reproducible preprocessing and modeling workflow that avoids data leakage.

sklearnpipelinecolumntransformerscikit-learn
Illustration of PCA reducing high-dimensional data to a lower-dimensional space using sklearn in Python.
Python

PCA for Dimensionality Reduction in Python with scikit-learn

Learn how to apply PCA with scikit-learn in Python: scale data, choose components, interpret results, and visualize high-dimensional data.

sklearnPCAdimensionality reductionmachine learning
Visual comparison of KMeans and DBSCAN clustering results on a scatter plot.
Python

KMeans vs DBSCAN: Clustering with Python and scikit-learn

Compare KMeans and DBSCAN for clustering with Python and scikit-learn. Understand their assumptions, implement each algorithm, choose parameters, and decide which fits your data.

scikit-learnKMeansDBSCANclustering
A visual comparison of SVM, KNN, and naive Bayes classifiers in scikit-learn showing decision boundaries.
Python

Comparing Python sklearn SVM, KNN, and Naive Bayes

Implement SVM, KNN, and Gaussian naive Bayes classifiers with scikit-learn, compare their tradeoffs, and choose the right algorithm for your data.

scikit-learnSVMKNNNaive Bayes
A visual representation of a decision tree splitting data and a random forest ensemble with feature importance bars.
Python

Python sklearn Decision Tree and Random Forest Feature Importance

Learn how to train decision trees and random forests in scikit-learn, extract feature importance scores, and interpret them accurately.

scikit-learndecision treerandom forestfeature importance
Illustration of linear and logistic regression models using scikit-learn in Python.
Python

Python Sklearn Linear and Logistic Regression

Practical guide to Python sklearn linear and logistic regression. Includes code examples, parameter choices, feature scaling, regularization, and model evaluation.

scikit-learnlinear-regressionlogistic-regressionmodel-evaluation
A diagram showing a data table with empty cells being filled by a SimpleImputer component before entering a machine learning pipeline.
Python

Handling Python sklearn Missing Values with SimpleImputer

How to handle missing values in scikit-learn with SimpleImputer: strategy choices, mixed column types, pipeline integration, and common pitfalls.

scikit-learndata preprocessingmissing valuesSimpleImputer
Diagram comparing label encoding and one-hot encoding of categorical data in scikit-learn
Python

Python sklearn Label Encoding and One Hot Encoding

Learn how to apply label encoding and one-hot encoding with scikit-learn, when each approach fits, and how to avoid common pitfalls with unseen categories.

scikit-learncategorical encodingdata preprocessingfeature engineering