Skip to content

Commit 8b33a6b

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 95628bfefbc8acf8688957476802e9696dcdbf03
1 parent a7b5aca commit 8b33a6b

File tree

1,047 files changed

+3168
-3162
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,047 files changed

+3168
-3162
lines changed
20 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.

dev/_downloads/plot_svm_anova.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"print(__doc__)\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import svm, datasets, feature_selection\nfrom sklearn.model_selection import cross_val_score\nfrom sklearn.pipeline import Pipeline\n\n# #############################################################################\n# Import some data to play with\ndigits = datasets.load_digits()\ny = digits.target\n# Throw away data, to be in the curse of dimension settings\ny = y[:200]\nX = digits.data[:200]\nn_samples = len(y)\nX = X.reshape((n_samples, -1))\n# add 200 non-informative features\nX = np.hstack((X, 2 * np.random.random((n_samples, 200))))\n\n# #############################################################################\n# Create a feature-selection transform and an instance of SVM that we\n# combine together to have an full-blown estimator\n\ntransform = feature_selection.SelectPercentile(feature_selection.f_classif)\n\nclf = Pipeline([('anova', transform), ('svc', svm.SVC(C=1.0))])\n\n# #############################################################################\n# Plot the cross-validation score as a function of percentile of features\nscore_means = list()\nscore_stds = list()\npercentiles = (1, 3, 6, 10, 15, 20, 30, 40, 60, 80, 100)\n\nfor percentile in percentiles:\n clf.set_params(anova__percentile=percentile)\n # Compute cross-validation score using 1 CPU\n this_scores = cross_val_score(clf, X, y, n_jobs=1)\n score_means.append(this_scores.mean())\n score_stds.append(this_scores.std())\n\nplt.errorbar(percentiles, score_means, np.array(score_stds))\n\nplt.title(\n 'Performance of the SVM-Anova varying the percentile of features selected')\nplt.xlabel('Percentile')\nplt.ylabel('Prediction rate')\n\nplt.axis('tight')\nplt.show()"
29+
"print(__doc__)\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.datasets import load_digits\nfrom sklearn.feature_selection import SelectPercentile, chi2\nfrom sklearn.model_selection import cross_val_score\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.svm import SVC\n\n\n# #############################################################################\n# Import some data to play with\nX, y = load_digits(return_X_y=True)\n# Throw away data, to be in the curse of dimension settings\nX = X[:200]\ny = y[:200]\nn_samples = len(y)\nX = X.reshape((n_samples, -1))\n# add 200 non-informative features\nX = np.hstack((X, 2 * np.random.random((n_samples, 200))))\n\n# #############################################################################\n# Create a feature-selection transform and an instance of SVM that we\n# combine together to have an full-blown estimator\n\ntransform = SelectPercentile(chi2)\n\nclf = Pipeline([('anova', transform), ('svc', SVC(gamma=\"auto\"))])\n\n# #############################################################################\n# Plot the cross-validation score as a function of percentile of features\nscore_means = list()\nscore_stds = list()\npercentiles = (1, 3, 6, 10, 15, 20, 30, 40, 60, 80, 100)\n\nfor percentile in percentiles:\n clf.set_params(anova__percentile=percentile)\n # Compute cross-validation score using 1 CPU\n this_scores = cross_val_score(clf, X, y, n_jobs=1)\n score_means.append(this_scores.mean())\n score_stds.append(this_scores.std())\n\nplt.errorbar(percentiles, score_means, np.array(score_stds))\n\nplt.title(\n 'Performance of the SVM-Anova varying the percentile of features selected')\nplt.xlabel('Percentile')\nplt.ylabel('Prediction rate')\n\nplt.axis('tight')\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/plot_svm_anova.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@
1010

1111
import numpy as np
1212
import matplotlib.pyplot as plt
13-
from sklearn import svm, datasets, feature_selection
13+
from sklearn.datasets import load_digits
14+
from sklearn.feature_selection import SelectPercentile, chi2
1415
from sklearn.model_selection import cross_val_score
1516
from sklearn.pipeline import Pipeline
17+
from sklearn.svm import SVC
18+
1619

1720
# #############################################################################
1821
# Import some data to play with
19-
digits = datasets.load_digits()
20-
y = digits.target
22+
X, y = load_digits(return_X_y=True)
2123
# Throw away data, to be in the curse of dimension settings
24+
X = X[:200]
2225
y = y[:200]
23-
X = digits.data[:200]
2426
n_samples = len(y)
2527
X = X.reshape((n_samples, -1))
2628
# add 200 non-informative features
@@ -30,9 +32,9 @@
3032
# Create a feature-selection transform and an instance of SVM that we
3133
# combine together to have an full-blown estimator
3234

33-
transform = feature_selection.SelectPercentile(feature_selection.f_classif)
35+
transform = SelectPercentile(chi2)
3436

35-
clf = Pipeline([('anova', transform), ('svc', svm.SVC(C=1.0))])
37+
clf = Pipeline([('anova', transform), ('svc', SVC(gamma="auto"))])
3638

3739
# #############################################################################
3840
# Plot the cross-validation score as a function of percentile of features

dev/_downloads/scikit-learn-docs.pdf

18.7 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes
167 Bytes
167 Bytes
30 Bytes
30 Bytes

0 commit comments

Comments
 (0)