Skip to content

Commit 48dbe8e

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 94366b83195b2c004e6576268ae7ee0d3b772c18
1 parent 539e3ae commit 48dbe8e

File tree

1,207 files changed

+3826
-3687
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,207 files changed

+3826
-3687
lines changed
Binary file not shown.

dev/_downloads/7ee55c12f8d3eb1dd8d2005d9dd7b6f1/plot_release_highlights_0_22_0.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,30 @@
117117

118118
titanic = fetch_openml('titanic', version=1, as_frame=True)
119119
print(titanic.data.head()[['pclass', 'embarked']])
120+
121+
############################################################################
122+
# Precomputed sparse nearest neighbors graph
123+
# ------------------------------------------
124+
# Most estimators based on nearest neighbors graphs now accept precomputed
125+
# sparse graphs as input, to reuse the same graph for multiple estimator fits.
126+
# To use this feature in a pipeline, one can use the `memory` parameter, along
127+
# with one of the two new transformers,
128+
# :class:`~sklearn.neighbors.KNeighborsTransformer` and
129+
# :class:`~sklearn.neighbors.RadiusNeighborsTransformer`. The precomputation
130+
# can also be performed by custom estimators to use alternative
131+
# implementations, such as approximate nearest neighbors methods.
132+
# See more details in the :ref:`User Guide <neighbors_transformer>`.
133+
134+
from sklearn.neighbors import KNeighborsTransformer
135+
from sklearn.manifold import Isomap
136+
from sklearn.pipeline import make_pipeline
137+
138+
estimator = make_pipeline(
139+
KNeighborsTransformer(n_neighbors=10, mode='distance'),
140+
Isomap(n_neighbors=10, metric='precomputed'),
141+
memory='.')
142+
estimator.fit(X)
143+
144+
# We can decrease the number of neighbors and the graph will not be recomputed.
145+
estimator.set_params(isomap__n_neighbors=5)
146+
estimator.fit(X)

dev/_downloads/c101b602d0b3510ef47dd19d64a4a92b/plot_release_highlights_0_22_0.ipynb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,24 @@
107107
"source": [
108108
"from sklearn.datasets import fetch_openml\n\ntitanic = fetch_openml('titanic', version=1, as_frame=True)\nprint(titanic.data.head()[['pclass', 'embarked']])"
109109
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"metadata": {},
114+
"source": [
115+
"Precomputed sparse nearest neighbors graph\n------------------------------------------\nMost estimators based on nearest neighbors graphs now accept precomputed\nsparse graphs as input, to reuse the same graph for multiple estimator fits.\nTo use this feature in a pipeline, one can use the `memory` parameter, along\nwith one of the two new transformers,\n:class:`~sklearn.neighbors.KNeighborsTransformer` and\n:class:`~sklearn.neighbors.RadiusNeighborsTransformer`. The precomputation\ncan also be performed by custom estimators to use alternative\nimplementations, such as approximate nearest neighbors methods.\nSee more details in the `User Guide <neighbors_transformer>`.\n\n"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": null,
121+
"metadata": {
122+
"collapsed": false
123+
},
124+
"outputs": [],
125+
"source": [
126+
"from sklearn.neighbors import KNeighborsTransformer\nfrom sklearn.manifold import Isomap\nfrom sklearn.pipeline import make_pipeline\n\nestimator = make_pipeline(\n KNeighborsTransformer(n_neighbors=10, mode='distance'),\n Isomap(n_neighbors=10, metric='precomputed'),\n memory='.')\nestimator.fit(X)\n\n# We can decrease the number of neighbors and the graph will not be recomputed.\nestimator.set_params(isomap__n_neighbors=5)\nestimator.fit(X)"
127+
]
110128
}
111129
],
112130
"metadata": {
Binary file not shown.

dev/_downloads/scikit-learn-docs.pdf

12.4 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes
124 Bytes
124 Bytes
-11 Bytes
-11 Bytes

0 commit comments

Comments
 (0)