Skip to content

Commit 13baeef

Browse files
committed
Pushing the docs to dev/ for branch: main, commit b260100656093f24e8682c6c8c66ef520a0c7fa3
1 parent f8d4423 commit 13baeef

File tree

1,204 files changed

+4427
-4318
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,204 files changed

+4427
-4318
lines changed
Binary file not shown.

dev/_downloads/437df39fcde24ead7b91917f2133a53c/plot_regression.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
# License: BSD 3 clause (C) INRIA
1616

1717

18-
# #############################################################################
18+
# %%
1919
# Generate sample data
20+
# --------------------
2021
import numpy as np
2122
import matplotlib.pyplot as plt
2223
from sklearn import neighbors
@@ -29,8 +30,9 @@
2930
# Add noise to targets
3031
y[::5] += 1 * (0.5 - np.random.rand(8))
3132

32-
# #############################################################################
33+
# %%
3334
# Fit regression model
35+
# --------------------
3436
n_neighbors = 5
3537

3638
for i, weights in enumerate(["uniform", "distance"]):
Binary file not shown.

dev/_downloads/8daa075623a97eefa5be2c4a6eb55992/plot_regression.ipynb

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,43 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"# Author: Alexandre Gramfort <[email protected]>\n# Fabian Pedregosa <[email protected]>\n#\n# License: BSD 3 clause (C) INRIA\n\n\n# #############################################################################\n# Generate sample data\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import neighbors\n\nnp.random.seed(0)\nX = np.sort(5 * np.random.rand(40, 1), axis=0)\nT = np.linspace(0, 5, 500)[:, np.newaxis]\ny = np.sin(X).ravel()\n\n# Add noise to targets\ny[::5] += 1 * (0.5 - np.random.rand(8))\n\n# #############################################################################\n# Fit regression model\nn_neighbors = 5\n\nfor i, weights in enumerate([\"uniform\", \"distance\"]):\n knn = neighbors.KNeighborsRegressor(n_neighbors, weights=weights)\n y_ = knn.fit(X, y).predict(T)\n\n plt.subplot(2, 1, i + 1)\n plt.scatter(X, y, color=\"darkorange\", label=\"data\")\n plt.plot(T, y_, color=\"navy\", label=\"prediction\")\n plt.axis(\"tight\")\n plt.legend()\n plt.title(\"KNeighborsRegressor (k = %i, weights = '%s')\" % (n_neighbors, weights))\n\nplt.tight_layout()\nplt.show()"
29+
"# Author: Alexandre Gramfort <[email protected]>\n# Fabian Pedregosa <[email protected]>\n#\n# License: BSD 3 clause (C) INRIA"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"## Generate sample data\n\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"collapsed": false
44+
},
45+
"outputs": [],
46+
"source": [
47+
"import numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import neighbors\n\nnp.random.seed(0)\nX = np.sort(5 * np.random.rand(40, 1), axis=0)\nT = np.linspace(0, 5, 500)[:, np.newaxis]\ny = np.sin(X).ravel()\n\n# Add noise to targets\ny[::5] += 1 * (0.5 - np.random.rand(8))"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"## Fit regression model\n\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"n_neighbors = 5\n\nfor i, weights in enumerate([\"uniform\", \"distance\"]):\n knn = neighbors.KNeighborsRegressor(n_neighbors, weights=weights)\n y_ = knn.fit(X, y).predict(T)\n\n plt.subplot(2, 1, i + 1)\n plt.scatter(X, y, color=\"darkorange\", label=\"data\")\n plt.plot(T, y_, color=\"navy\", label=\"prediction\")\n plt.axis(\"tight\")\n plt.legend()\n plt.title(\"KNeighborsRegressor (k = %i, weights = '%s')\" % (n_neighbors, weights))\n\nplt.tight_layout()\nplt.show()"
3066
]
3167
}
3268
],

dev/_downloads/scikit-learn-docs.zip

-498 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)