Skip to content

Commit 10f272d

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 5d145bf760539d40f4e2c50c0f4c46200945c978
1 parent 485da15 commit 10f272d

File tree

1,457 files changed

+7995
-7608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,457 files changed

+7995
-7608
lines changed

dev/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 532532c020da4c5a5fd3c1222d624cbe
3+
config: 876bf1130acd94fa0034f5c0777d7383
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

dev/_downloads/067cd5d39b097d2c49dd98f563dac13a/plot_iterative_imputer_variants_comparison.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n# Imputing missing values with variants of IterativeImputer\n\n.. currentmodule:: sklearn\n\nThe :class:`~impute.IterativeImputer` class is very flexible - it can be\nused with a variety of estimators to do round-robin regression, treating every\nvariable as an output in turn.\n\nIn this example we compare some estimators for the purpose of missing feature\nimputation with :class:`~impute.IterativeImputer`:\n\n* :class:`~linear_model.BayesianRidge`: regularized linear regression\n* :class:`~tree.RandomForestRegressor`: Forests of randomized trees regression\n* :func:`~pipeline.make_pipeline`(:class:`~kernel_approximation.Nystroem`,\n :class:`~linear_model.Ridge`): a pipeline with the expansion of a degree 2\n polynomial kernel and regularized linear regression\n* :class:`~neighbors.KNeighborsRegressor`: comparable to other KNN\n imputation approaches\n\nOf particular interest is the ability of\n:class:`~impute.IterativeImputer` to mimic the behavior of missForest, a\npopular imputation package for R.\n\nNote that :class:`~neighbors.KNeighborsRegressor` is different from KNN\nimputation, which learns from samples with missing values by using a distance\nmetric that accounts for missing values, rather than imputing them.\n\nThe goal is to compare different estimators to see which one is best for the\n:class:`~impute.IterativeImputer` when using a\n:class:`~linear_model.BayesianRidge` estimator on the California housing\ndataset with a single value randomly removed from each row.\n\nFor this particular pattern of missing values we see that\n:class:`~linear_model.BayesianRidge` and\n:class:`~ensemble.RandomForestRegressor` give the best results.\n\nIt should be noted that some estimators such as\n:class:`~ensemble.HistGradientBoostingRegressor` can natively deal with\nmissing features and are often recommended over building pipelines with\ncomplex and costly missing values imputation strategies.\n"
7+
"\n# Imputing missing values with variants of IterativeImputer\n\n.. currentmodule:: sklearn\n\nThe :class:`~impute.IterativeImputer` class is very flexible - it can be\nused with a variety of estimators to do round-robin regression, treating every\nvariable as an output in turn.\n\nIn this example we compare some estimators for the purpose of missing feature\nimputation with :class:`~impute.IterativeImputer`:\n\n* :class:`~linear_model.BayesianRidge`: regularized linear regression\n* :class:`~ensemble.RandomForestRegressor`: Forests of randomized trees regression\n* :func:`~pipeline.make_pipeline` (:class:`~kernel_approximation.Nystroem`,\n :class:`~linear_model.Ridge`): a pipeline with the expansion of a degree 2\n polynomial kernel and regularized linear regression\n* :class:`~neighbors.KNeighborsRegressor`: comparable to other KNN\n imputation approaches\n\nOf particular interest is the ability of\n:class:`~impute.IterativeImputer` to mimic the behavior of missForest, a\npopular imputation package for R.\n\nNote that :class:`~neighbors.KNeighborsRegressor` is different from KNN\nimputation, which learns from samples with missing values by using a distance\nmetric that accounts for missing values, rather than imputing them.\n\nThe goal is to compare different estimators to see which one is best for the\n:class:`~impute.IterativeImputer` when using a\n:class:`~linear_model.BayesianRidge` estimator on the California housing\ndataset with a single value randomly removed from each row.\n\nFor this particular pattern of missing values we see that\n:class:`~linear_model.BayesianRidge` and\n:class:`~ensemble.RandomForestRegressor` give the best results.\n\nIt should be noted that some estimators such as\n:class:`~ensemble.HistGradientBoostingRegressor` can natively deal with\nmissing features and are often recommended over building pipelines with\ncomplex and costly missing values imputation strategies.\n"
88
]
99
},
1010
{
Binary file not shown.

dev/_downloads/091282551e0bf11fedc96b869dfa8408/plot_grid_search_text_feature_extraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# ------------
2626
# We load two categories from the training set. You can adjust the number of
2727
# categories by adding their names to the list or setting `categories=None` when
28-
# calling the dataset loader :func:`~sklearn.datasets.fetch20newsgroups` to get
28+
# calling the dataset loader :func:`~sklearn.datasets.fetch_20newsgroups` to get
2929
# the 20 of them.
3030

3131
from sklearn.datasets import fetch_20newsgroups

dev/_downloads/1054d40caffbd65c52b20dac784c7c5c/plot_elastic_net_precomputed_gram_matrix_with_weighted_samples.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n# Fitting an Elastic Net with a precomputed Gram Matrix and Weighted Samples\n\nThe following example shows how to precompute the gram matrix\nwhile using weighted samples with an ElasticNet.\n\nIf weighted samples are used, the design matrix must be centered and then\nrescaled by the square root of the weight vector before the gram matrix\nis computed.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>`sample_weight` vector is also rescaled to sum to `n_samples`, see the\n documentation for the `sample_weight` parameter to\n :func:`linear_model.ElasticNet.fit`.</p></div>\n"
7+
"\n# Fitting an Elastic Net with a precomputed Gram Matrix and Weighted Samples\n\nThe following example shows how to precompute the gram matrix\nwhile using weighted samples with an :class:`~sklearn.linear_model.ElasticNet`.\n\nIf weighted samples are used, the design matrix must be centered and then\nrescaled by the square root of the weight vector before the gram matrix\nis computed.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>`sample_weight` vector is also rescaled to sum to `n_samples`, see the\n documentation for the `sample_weight` parameter to\n :meth:`~sklearn.linear_model.ElasticNet.fit`.</p></div>\n"
88
]
99
},
1010
{

dev/_downloads/2f3ef774a6d7e52e1e6b7ccbb75d25f0/plot_gradient_boosting_quantile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ def f(x):
128128
# Analysis of the error metrics
129129
# -----------------------------
130130
#
131-
# Measure the models with :func:`mean_squared_error` and
132-
# :func:`mean_pinball_loss` metrics on the training dataset.
131+
# Measure the models with :func:`~sklearn.metrics.mean_squared_error` and
132+
# :func:`~sklearn.metrics.mean_pinball_loss` metrics on the training dataset.
133133
import pandas as pd
134134

135135

@@ -156,7 +156,7 @@ def highlight_min(x):
156156
# training converged.
157157
#
158158
# Note that because the target distribution is asymmetric, the expected
159-
# conditional mean and conditional median are signficiantly different and
159+
# conditional mean and conditional median are significantly different and
160160
# therefore one could not use the squared error model get a good estimation of
161161
# the conditional median nor the converse.
162162
#
@@ -194,7 +194,7 @@ def highlight_min(x):
194194
# --------------------------------------
195195
#
196196
# We can also evaluate the ability of the two extreme quantile estimators at
197-
# producing a well-calibrated conditational 90%-confidence interval.
197+
# producing a well-calibrated conditional 90%-confidence interval.
198198
#
199199
# To do this we can compute the fraction of observations that fall between the
200200
# predictions:

dev/_downloads/3992a64e742c874f5df2ba26ae9c049b/plot_grid_search_text_feature_extraction.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"cell_type": "markdown",
2323
"metadata": {},
2424
"source": [
25-
"## Data loading\nWe load two categories from the training set. You can adjust the number of\ncategories by adding their names to the list or setting `categories=None` when\ncalling the dataset loader :func:`~sklearn.datasets.fetch20newsgroups` to get\nthe 20 of them.\n\n"
25+
"## Data loading\nWe load two categories from the training set. You can adjust the number of\ncategories by adding their names to the list or setting `categories=None` when\ncalling the dataset loader :func:`~sklearn.datasets.fetch_20newsgroups` to get\nthe 20 of them.\n\n"
2626
]
2727
},
2828
{

dev/_downloads/40f4aad91af595a370d7582e3a23bed7/plot_roc.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"cell_type": "markdown",
113113
"metadata": {},
114114
"source": [
115-
"### ROC curve using micro-averaged OvR\n\nMicro-averaging aggregates the contributions from all the classes (using\n:func:`np.ravel`) to compute the average metrics as follows:\n\n$TPR=\\frac{\\sum_{c}TP_c}{\\sum_{c}(TP_c + FN_c)}$ ;\n\n$FPR=\\frac{\\sum_{c}FP_c}{\\sum_{c}(FP_c + TN_c)}$ .\n\nWe can briefly demo the effect of :func:`np.ravel`:\n\n"
115+
"### ROC curve using micro-averaged OvR\n\nMicro-averaging aggregates the contributions from all the classes (using\n:func:`numpy.ravel`) to compute the average metrics as follows:\n\n$TPR=\\frac{\\sum_{c}TP_c}{\\sum_{c}(TP_c + FN_c)}$ ;\n\n$FPR=\\frac{\\sum_{c}FP_c}{\\sum_{c}(FP_c + TN_c)}$ .\n\nWe can briefly demo the effect of :func:`numpy.ravel`:\n\n"
116116
]
117117
},
118118
{

dev/_downloads/4825fc8223d1af0f3b61080c3dea3a62/plot_faces_decomposition.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
This example applies to :ref:`olivetti_faces_dataset` different unsupervised
77
matrix decomposition (dimension reduction) methods from the module
8-
:py:mod:`sklearn.decomposition` (see the documentation chapter
8+
:mod:`sklearn.decomposition` (see the documentation chapter
99
:ref:`decompositions`).
1010
1111
@@ -146,9 +146,10 @@ def plot_gallery(title, images, n_col=n_col, n_row=n_row, cmap=plt.cm.gray):
146146
# Sparse components - MiniBatchSparsePCA
147147
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
148148
#
149-
# Mini-batch sparse PCA (`MiniBatchSparsePCA`) extracts the set of sparse
150-
# components that best reconstruct the data. This variant is faster but
151-
# less accurate than the similar :py:mod:`sklearn.decomposition.SparsePCA`.
149+
# Mini-batch sparse PCA (:class:`~sklearn.decomposition.MiniBatchSparsePCA`)
150+
# extracts the set of sparse components that best reconstruct the data. This
151+
# variant is faster but less accurate than the similar
152+
# :class:`~sklearn.decomposition.SparsePCA`.
152153

153154
# %%
154155
batch_pca_estimator = decomposition.MiniBatchSparsePCA(
@@ -164,9 +165,9 @@ def plot_gallery(title, images, n_col=n_col, n_row=n_row, cmap=plt.cm.gray):
164165
# Dictionary learning
165166
# ^^^^^^^^^^^^^^^^^^^
166167
#
167-
# By default, :class:`MiniBatchDictionaryLearning` divides the data into
168-
# mini-batches and optimizes in an online manner by cycling over the
169-
# mini-batches for the specified number of iterations.
168+
# By default, :class:`~sklearn.decomposition.MiniBatchDictionaryLearning`
169+
# divides the data into mini-batches and optimizes in an online manner by
170+
# cycling over the mini-batches for the specified number of iterations.
170171

171172
# %%
172173
batch_dict_estimator = decomposition.MiniBatchDictionaryLearning(
@@ -179,9 +180,11 @@ def plot_gallery(title, images, n_col=n_col, n_row=n_row, cmap=plt.cm.gray):
179180
# Cluster centers - MiniBatchKMeans
180181
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
181182
#
182-
# `MiniBatchKMeans` is computationally efficient and implements on-line
183-
# learning with a `partial_fit` method. That is why it could be beneficial
184-
# to enhance some time-consuming algorithms with `MiniBatchKMeans`.
183+
# :class:`sklearn.cluster.MiniBatchKMeans` is computationally efficient and
184+
# implements on-line learning with a
185+
# :meth:`~sklearn.decomposition.MiniBatchKMeans.partial_fit` method. That is
186+
# why it could be beneficial to enhance some time-consuming algorithms with
187+
# :class:`~sklearn.cluster.MiniBatchKMeans`.
185188

186189
# %%
187190
kmeans_estimator = cluster.MiniBatchKMeans(
@@ -203,10 +206,10 @@ def plot_gallery(title, images, n_col=n_col, n_row=n_row, cmap=plt.cm.gray):
203206
# Factor Analysis components - FA
204207
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
205208
#
206-
# `Factor Analysis` is similar to `PCA` but has the advantage of modelling the
207-
# variance in every direction of the input space independently
208-
# (heteroscedastic noise).
209-
# Read more in the :ref:`User Guide <FA>`.
209+
# :class:`~sklearn.decomposition.FactorAnalysis` is similar to
210+
# :class:`~sklearn.decomposition.PCA` but has the advantage of modelling the
211+
# variance in every direction of the input space independently (heteroscedastic
212+
# noise). Read more in the :ref:`User Guide <FA>`.
210213

211214
# %%
212215
fa_estimator = decomposition.FactorAnalysis(n_components=n_components, max_iter=20)
@@ -239,9 +242,10 @@ def plot_gallery(title, images, n_col=n_col, n_row=n_row, cmap=plt.cm.gray):
239242
# a dictionary. It is possible to constrain the dictionary and/or coding coefficients
240243
# to be positive to match constraints that may be present in the data.
241244
#
242-
# :class:`MiniBatchDictionaryLearning` implements a faster, but less accurate
243-
# version of the dictionary learning algorithm that is better suited for large
244-
# datasets. Read more in the :ref:`User Guide <MiniBatchDictionaryLearning>`.
245+
# :class:`~sklearn.decomposition.MiniBatchDictionaryLearning` implements a
246+
# faster, but less accurate version of the dictionary learning algorithm that
247+
# is better suited for large datasets. Read more in the :ref:`User Guide
248+
# <MiniBatchDictionaryLearning>`.
245249

246250
# %%
247251
# Plot the same samples from our dataset but with another colormap.
@@ -252,11 +256,11 @@ def plot_gallery(title, images, n_col=n_col, n_row=n_row, cmap=plt.cm.gray):
252256

253257
# %%
254258
# Similar to the previous examples, we change parameters and train
255-
# `MiniBatchDictionaryLearning` estimator on all images. Generally,
256-
# the dictionary learning and sparse encoding decompose input data
257-
# into the dictionary and the coding coefficients matrices.
258-
# :math:`X \approx UV`, where :math:`X = [x_1, . . . , x_n]`,
259-
# :math:`X \in \mathbb{R}^{m×n}`, dictionary :math:`U \in \mathbb{R}^{m×k}`, coding
259+
# :class:`~sklearn.decomposition.MiniBatchDictionaryLearning` estimator on all
260+
# images. Generally, the dictionary learning and sparse encoding decompose
261+
# input data into the dictionary and the coding coefficients matrices. :math:`X
262+
# \approx UV`, where :math:`X = [x_1, . . . , x_n]`, :math:`X \in
263+
# \mathbb{R}^{m×n}`, dictionary :math:`U \in \mathbb{R}^{m×k}`, coding
260264
# coefficients :math:`V \in \mathbb{R}^{k×n}`.
261265
#
262266
# Also below are the results when the dictionary and coding

dev/_downloads/4cf0456267ced0f869a458ef4776d4c5/plot_release_highlights_1_1_0.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# %%
2525
# Quantile loss in :class:`ensemble.HistGradientBoostingRegressor`
2626
# ----------------------------------------------------------------
27-
# :class:`ensemble.HistGradientBoostingRegressor` can model quantiles with
27+
# :class:`~ensemble.HistGradientBoostingRegressor` can model quantiles with
2828
# `loss="quantile"` and the new parameter `quantile`.
2929
from sklearn.ensemble import HistGradientBoostingRegressor
3030
import numpy as np
@@ -56,7 +56,7 @@
5656
# `get_feature_names_out` Available in all Transformers
5757
# -----------------------------------------------------
5858
# :term:`get_feature_names_out` is now available in all Transformers. This enables
59-
# :class:`pipeline.Pipeline` to construct the output feature names for more complex
59+
# :class:`~pipeline.Pipeline` to construct the output feature names for more complex
6060
# pipelines:
6161
from sklearn.compose import ColumnTransformer
6262
from sklearn.preprocessing import OneHotEncoder, StandardScaler
@@ -101,12 +101,13 @@
101101

102102

103103
# %%
104-
# Grouping infrequent categories in :class:`OneHotEncoder`
105-
# --------------------------------------------------------
106-
# :class:`OneHotEncoder` supports aggregating infrequent categories into a single
107-
# output for each feature. The parameters to enable the gathering of infrequent
108-
# categories are `min_frequency` and `max_categories`. See the
109-
# :ref:`User Guide <encoder_infrequent_categories>` for more details.
104+
# Grouping infrequent categories in :class:`~preprocessing.OneHotEncoder`
105+
# -----------------------------------------------------------------------
106+
# :class:`~preprocessing.OneHotEncoder` supports aggregating infrequent
107+
# categories into a single output for each feature. The parameters to enable
108+
# the gathering of infrequent categories are `min_frequency` and
109+
# `max_categories`. See the :ref:`User Guide <encoder_infrequent_categories>`
110+
# for more details.
110111
from sklearn.preprocessing import OneHotEncoder
111112
import numpy as np
112113

@@ -165,14 +166,15 @@
165166
# - :class:`linear_model.TweedieRegressor`
166167

167168
# %%
168-
# MiniBatchNMF: an online version of NMF
169-
# --------------------------------------
170-
# The new class :class:`decomposition.MiniBatchNMF` implements a faster but less
171-
# accurate version of non-negative matrix factorization (:class:`decomposition.NMF`).
172-
# :class:`MiniBatchNMF` divides the data into mini-batches and optimizes the NMF model
173-
# in an online manner by cycling over the mini-batches, making it better suited for
174-
# large datasets. In particular, it implements `partial_fit`, which can be used for
175-
# online learning when the data is not readily available from the start, or when the
169+
# :class:`~decomposition.MiniBatchNMF`: an online version of NMF
170+
# --------------------------------------------------------------
171+
# The new class :class:`~decomposition.MiniBatchNMF` implements a faster but
172+
# less accurate version of non-negative matrix factorization
173+
# (:class:`~decomposition.NMF`). :class:`~decomposition.MiniBatchNMF` divides the
174+
# data into mini-batches and optimizes the NMF model in an online manner by
175+
# cycling over the mini-batches, making it better suited for large datasets. In
176+
# particular, it implements `partial_fit`, which can be used for online
177+
# learning when the data is not readily available from the start, or when the
176178
# data does not fit into memory.
177179
import numpy as np
178180
from sklearn.decomposition import MiniBatchNMF
@@ -198,13 +200,14 @@
198200
)
199201

200202
# %%
201-
# BisectingKMeans: divide and cluster
202-
# -----------------------------------
203-
# The new class :class:`cluster.BisectingKMeans` is a variant of :class:`KMeans`, using
204-
# divisive hierarchical clustering. Instead of creating all centroids at once, centroids
205-
# are picked progressively based on a previous clustering: a cluster is split into two
206-
# new clusters repeatedly until the target number of clusters is reached, giving a
207-
# hierarchical structure to the clustering.
203+
# :class:`~cluster.BisectingKMeans`: divide and cluster
204+
# -----------------------------------------------------
205+
# The new class :class:`~cluster.BisectingKMeans` is a variant of
206+
# :class:`~cluster.KMeans`, using divisive hierarchical clustering. Instead of
207+
# creating all centroids at once, centroids are picked progressively based on a
208+
# previous clustering: a cluster is split into two new clusters repeatedly
209+
# until the target number of clusters is reached, giving a hierarchical
210+
# structure to the clustering.
208211
from sklearn.datasets import make_blobs
209212
from sklearn.cluster import KMeans, BisectingKMeans
210213
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)