Examples¶
Release Highlights¶
These examples illustrate the main features of the releases of scikit-learn.
Biclustering¶
Examples concerning biclustering techniques.
![](../_images/sphx_glr_plot_bicluster_newsgroups_thumb.png)
Biclustering documents with the Spectral Co-clustering algorithm
Calibration¶
Examples illustrating the calibration of predicted probabilities of classifiers.
![](../_images/sphx_glr_plot_calibration_multiclass_thumb.png)
Probability Calibration for 3-class classification
Classification¶
General examples about classification algorithms.
![](../_images/sphx_glr_plot_lda_qda_thumb.png)
Linear and Quadratic Discriminant Analysis with covariance ellipsoid
![](../_images/sphx_glr_plot_lda_thumb.png)
Normal, Ledoit-Wolf and OAS Linear Discriminant Analysis for classification
Clustering¶
Examples concerning the sklearn.cluster
module.
![](../_images/sphx_glr_plot_kmeans_digits_thumb.png)
A demo of K-Means clustering on the handwritten digits data
![](../_images/sphx_glr_plot_coin_ward_segmentation_thumb.png)
A demo of structured Ward hierarchical clustering on an image of coins
![](../_images/sphx_glr_plot_adjusted_for_chance_measures_thumb.png)
Adjustment for chance in clustering performance evaluation
![](../_images/sphx_glr_plot_agglomerative_clustering_thumb.png)
Agglomerative clustering with and without structure
![](../_images/sphx_glr_plot_bisect_kmeans_thumb.png)
Bisecting K-Means and Regular K-Means Performance Comparison
![](../_images/sphx_glr_plot_cluster_comparison_thumb.png)
Comparing different clustering algorithms on toy datasets
![](../_images/sphx_glr_plot_linkage_comparison_thumb.png)
Comparing different hierarchical linkage methods on toy datasets
![](../_images/sphx_glr_plot_mini_batch_kmeans_thumb.png)
Comparison of the K-Means and MiniBatchKMeans clustering algorithms
![](../_images/sphx_glr_plot_kmeans_stability_low_dim_dense_thumb.png)
Empirical evaluation of the impact of k-means initialization
![](../_images/sphx_glr_plot_ward_structured_vs_unstructured_thumb.png)
Hierarchical clustering: structured vs unstructured ward
![](../_images/sphx_glr_plot_kmeans_silhouette_analysis_thumb.png)
Selecting the number of clusters with silhouette analysis on KMeans clustering
![](../_images/sphx_glr_plot_digits_linkage_thumb.png)
Various Agglomerative Clustering on a 2D embedding of digits
Covariance estimation¶
Examples concerning the sklearn.covariance
module.
![](../_images/sphx_glr_plot_mahalanobis_distances_thumb.png)
Robust covariance estimation and Mahalanobis distances relevance
![](../_images/sphx_glr_plot_covariance_estimation_thumb.png)
Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood
Cross decomposition¶
Examples concerning the sklearn.cross_decomposition
module.
![](../_images/sphx_glr_plot_pcr_vs_pls_thumb.png)
Principal Component Regression vs Partial Least Squares Regression
Dataset examples¶
Examples concerning the sklearn.datasets
module.
Decision Trees¶
Examples concerning the sklearn.tree
module.
![](../_images/sphx_glr_plot_iris_dtc_thumb.png)
Plot the decision surface of decision trees trained on the iris dataset
![](../_images/sphx_glr_plot_cost_complexity_pruning_thumb.png)
Post pruning decision trees with cost complexity pruning
Decomposition¶
Examples concerning the sklearn.decomposition
module.
![](../_images/sphx_glr_plot_pca_vs_lda_thumb.png)
Comparison of LDA and PCA 2D projection of Iris dataset
![](../_images/sphx_glr_plot_varimax_fa_thumb.png)
Factor Analysis (with rotation) to visualize patterns
![](../_images/sphx_glr_plot_pca_vs_fa_model_selection_thumb.png)
Model selection with Probabilistic PCA and Factor Analysis (FA)
Developing Estimators¶
Examples concerning the development of Custom Estimator.
Ensemble methods¶
Examples concerning the sklearn.ensemble
module.
![](../_images/sphx_glr_plot_forest_hist_grad_boosting_comparison_thumb.png)
Comparing Random Forests and Histogram Gradient Boosting models
![](../_images/sphx_glr_plot_random_forest_regression_multioutput_thumb.png)
Comparing random forests and the multi-output meta estimator
![](../_images/sphx_glr_plot_random_forest_embedding_thumb.png)
Hashing feature transformation using Totally Random Trees
![](../_images/sphx_glr_plot_voting_probas_thumb.png)
Plot class probabilities calculated by the VotingClassifier
![](../_images/sphx_glr_plot_voting_decision_regions_thumb.png)
Plot the decision boundaries of a VotingClassifier
![](../_images/sphx_glr_plot_forest_iris_thumb.png)
Plot the decision surfaces of ensembles of trees on the iris dataset
![](../_images/sphx_glr_plot_gradient_boosting_quantile_thumb.png)
Prediction Intervals for Gradient Boosting Regression
![](../_images/sphx_glr_plot_bias_variance_thumb.png)
Single estimator versus bagging: bias-variance decomposition
Examples based on real world datasets¶
Applications to real world problems with some medium sized datasets or interactive user interface.
![](../_images/sphx_glr_plot_tomography_l1_reconstruction_thumb.png)
Compressive sensing: tomography reconstruction with L1 prior (Lasso)
![](../_images/sphx_glr_plot_face_recognition_thumb.png)
Faces recognition example using eigenfaces and SVMs
![](../_images/sphx_glr_plot_topics_extraction_with_nmf_lda_thumb.png)
Topic extraction with Non-negative Matrix Factorization and Latent Dirichlet Allocation
Feature Selection¶
Examples concerning the sklearn.feature_selection
module.
![](../_images/sphx_glr_plot_rfe_with_cross_validation_thumb.png)
Recursive feature elimination with cross-validation
Gaussian Mixture Models¶
Examples concerning the sklearn.mixture
module.
![](../_images/sphx_glr_plot_concentration_prior_thumb.png)
Concentration Prior Type Analysis of Variation Bayesian Gaussian Mixture
Gaussian Process for Machine Learning¶
Examples concerning the sklearn.gaussian_process
module.
![](../_images/sphx_glr_plot_gpr_noisy_thumb.png)
Ability of Gaussian process regression (GPR) to estimate data noise-level
![](../_images/sphx_glr_plot_compare_gpr_krr_thumb.png)
Comparison of kernel ridge and Gaussian process regression
![](../_images/sphx_glr_plot_gpr_co2_thumb.png)
Forecasting of CO2 level on Mona Loa dataset using Gaussian process regression (GPR)
![](../_images/sphx_glr_plot_gpr_noisy_targets_thumb.png)
Gaussian Processes regression: basic introductory example
![](../_images/sphx_glr_plot_gpc_iris_thumb.png)
Gaussian process classification (GPC) on iris dataset
![](../_images/sphx_glr_plot_gpc_xor_thumb.png)
Illustration of Gaussian process classification (GPC) on the XOR dataset
![](../_images/sphx_glr_plot_gpr_prior_posterior_thumb.png)
Illustration of prior and posterior Gaussian process for different kernels
![](../_images/sphx_glr_plot_gpc_isoprobability_thumb.png)
Iso-probability lines for Gaussian Processes classification (GPC)
![](../_images/sphx_glr_plot_gpc_thumb.png)
Probabilistic predictions with Gaussian process classification (GPC)
Generalized Linear Models¶
Examples concerning the sklearn.linear_model
module.
![](../_images/sphx_glr_plot_elastic_net_precomputed_gram_matrix_with_weighted_samples_thumb.png)
Fitting an Elastic Net with a precomputed Gram Matrix and Weighted Samples
![](../_images/sphx_glr_plot_huber_vs_ridge_thumb.png)
HuberRegressor vs Ridge on dataset with strong outliers
![](../_images/sphx_glr_plot_sparse_logistic_regression_mnist_thumb.png)
MNIST classification using multinomial logistic + L1
![](../_images/sphx_glr_plot_sparse_logistic_regression_20newsgroups_thumb.png)
Multiclass sparse logistic regression on 20newgroups
![](../_images/sphx_glr_plot_sgdocsvm_vs_ocsvm_thumb.png)
One-Class SVM versus One-Class SVM using Stochastic Gradient Descent
![](../_images/sphx_glr_plot_ols_ridge_variance_thumb.png)
Ordinary Least Squares and Ridge Regression Variance
![](../_images/sphx_glr_plot_ridge_path_thumb.png)
Plot Ridge coefficients as a function of the regularization
![](../_images/sphx_glr_plot_logistic_multinomial_thumb.png)
Plot multinomial and One-vs-Rest Logistic Regression
![](../_images/sphx_glr_plot_ridge_coeffs_thumb.png)
Ridge coefficients as a function of the L2 Regularization
Inspection¶
Examples related to the sklearn.inspection
module.
![](../_images/sphx_glr_plot_linear_model_coefficient_interpretation_thumb.png)
Common pitfalls in the interpretation of coefficients of linear models
![](../_images/sphx_glr_plot_causal_interpretation_thumb.png)
Failure of Machine Learning to infer causal effects
![](../_images/sphx_glr_plot_partial_dependence_thumb.png)
Partial Dependence and Individual Conditional Expectation Plots
![](../_images/sphx_glr_plot_permutation_importance_thumb.png)
Permutation Importance vs Random Forest Feature Importance (MDI)
![](../_images/sphx_glr_plot_permutation_importance_multicollinear_thumb.png)
Permutation Importance with Multicollinear or Correlated Features
Kernel Approximation¶
Examples concerning the sklearn.kernel_approximation
module.
![](../_images/sphx_glr_plot_scalable_poly_kernels_thumb.png)
Scalable learning with polynomial kernel approximation
Manifold learning¶
Examples concerning the sklearn.manifold
module.
![](../_images/sphx_glr_plot_lle_digits_thumb.png)
Manifold learning on handwritten digits: Locally Linear Embedding, Isomap…
![](../_images/sphx_glr_plot_t_sne_perplexity_thumb.png)
t-SNE: The effect of various perplexity values on the shape
Miscellaneous¶
Miscellaneous and introductory examples for scikit-learn.
![](../_images/sphx_glr_plot_anomaly_comparison_thumb.png)
Comparing anomaly detection algorithms for outlier detection on toy datasets
![](../_images/sphx_glr_plot_kernel_approximation_thumb.png)
Explicit feature map approximation for RBF kernels
![](../_images/sphx_glr_plot_johnson_lindenstrauss_bound_thumb.png)
The Johnson-Lindenstrauss bound for embedding with random projections
Missing Value Imputation¶
Examples concerning the sklearn.impute
module.
![](../_images/sphx_glr_plot_missing_values_thumb.png)
Imputing missing values before building an estimator
![](../_images/sphx_glr_plot_iterative_imputer_variants_comparison_thumb.png)
Imputing missing values with variants of IterativeImputer
Model Selection¶
Examples related to the sklearn.model_selection
module.
![](../_images/sphx_glr_plot_grid_search_refit_callable_thumb.png)
Balance model complexity and cross-validated score
![](../_images/sphx_glr_plot_likelihood_ratios_thumb.png)
Class Likelihood Ratios to measure classification performance
![](../_images/sphx_glr_plot_randomized_search_thumb.png)
Comparing randomized search and grid search for hyperparameter estimation
![](../_images/sphx_glr_plot_successive_halving_heatmap_thumb.png)
Comparison between grid search and successive halving
![](../_images/sphx_glr_plot_grid_search_digits_thumb.png)
Custom refit strategy of a grid search with cross-validation
![](../_images/sphx_glr_plot_multi_metric_evaluation_thumb.png)
Demonstration of multi-metric evaluation on cross_val_score and GridSearchCV
![](../_images/sphx_glr_plot_roc_thumb.png)
Multiclass Receiver Operating Characteristic (ROC)
![](../_images/sphx_glr_plot_learning_curve_thumb.png)
Plotting Learning Curves and Checking Models’ Scalability
![](../_images/sphx_glr_plot_roc_crossval_thumb.png)
Receiver Operating Characteristic (ROC) with cross validation
![](../_images/sphx_glr_plot_grid_search_text_feature_extraction_thumb.png)
Sample pipeline for text feature extraction and evaluation
![](../_images/sphx_glr_plot_grid_search_stats_thumb.png)
Statistical comparison of models using grid search
![](../_images/sphx_glr_plot_permutation_tests_for_classification_thumb.png)
Test with permutations the significance of a classification score
![](../_images/sphx_glr_plot_cv_indices_thumb.png)
Visualizing cross-validation behavior in scikit-learn
Multioutput methods¶
Examples concerning the sklearn.multioutput
module.
Nearest Neighbors¶
Examples concerning the sklearn.neighbors
module.
![](../_images/sphx_glr_plot_nca_classification_thumb.png)
Comparing Nearest Neighbors with and without Neighborhood Components Analysis
![](../_images/sphx_glr_plot_nca_dim_reduction_thumb.png)
Dimensionality Reduction with Neighborhood Components Analysis
Neural Networks¶
Examples concerning the sklearn.neural_network
module.
![](../_images/sphx_glr_plot_mlp_training_curves_thumb.png)
Compare Stochastic learning strategies for MLPClassifier
![](../_images/sphx_glr_plot_rbm_logistic_classification_thumb.png)
Restricted Boltzmann Machine features for digit classification
Pipelines and composite estimators¶
Examples of how to compose transformers and pipelines from other estimators. See the User Guide.
![](../_images/sphx_glr_plot_column_transformer_thumb.png)
Column Transformer with Heterogeneous Data Sources
![](../_images/sphx_glr_plot_transformed_target_thumb.png)
Effect of transforming the targets in regression model
![](../_images/sphx_glr_plot_digits_pipe_thumb.png)
Pipelining: chaining a PCA and a logistic regression
![](../_images/sphx_glr_plot_compare_reduction_thumb.png)
Selecting dimensionality reduction with Pipeline and GridSearchCV
Preprocessing¶
Examples concerning the sklearn.preprocessing
module.
![](../_images/sphx_glr_plot_all_scaling_thumb.png)
Compare the effect of different scalers on data with outliers
![](../_images/sphx_glr_plot_discretization_strategies_thumb.png)
Demonstrating the different strategies of KBinsDiscretizer
![](../_images/sphx_glr_plot_discretization_thumb.png)
Using KBinsDiscretizer to discretize continuous features
Semi Supervised Classification¶
Examples concerning the sklearn.semi_supervised
module.
![](../_images/sphx_glr_plot_semi_supervised_versus_svm_iris_thumb.png)
Decision boundary of semi-supervised classifiers versus SVM on the Iris dataset
![](../_images/sphx_glr_plot_label_propagation_digits_thumb.png)
Label Propagation digits: Demonstrating performance
Support Vector Machines¶
Examples concerning the sklearn.svm
module.
![](../_images/sphx_glr_plot_svm_kernels_thumb.png)
Plot classification boundaries with different SVM Kernels
![](../_images/sphx_glr_plot_iris_svc_thumb.png)
Plot different SVM classifiers in the iris dataset
![](../_images/sphx_glr_plot_svm_regression_thumb.png)
Support Vector Regression (SVR) using linear and non-linear kernels
Tutorial exercises¶
Exercises for the tutorials
Working with text documents¶
Examples concerning the sklearn.feature_extraction.text
module.
![](../_images/sphx_glr_plot_document_classification_20newsgroups_thumb.png)
Classification of text documents using sparse features