Skip to content

Commit a55308a

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 14764061f81b4db311faebe4dc8b2615d8750f29
1 parent b30d4e1 commit a55308a

File tree

1,092 files changed

+3429
-3837
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,092 files changed

+3429
-3837
lines changed
-160 Bytes
Binary file not shown.
-155 Bytes
Binary file not shown.

dev/_downloads/plot_compare_calibration.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Comparison of Calibration of Classifiers\n\n\nWell calibrated classifiers are probabilistic classifiers for which the output\nof the predict_proba method can be directly interpreted as a confidence level.\nFor instance a well calibrated (binary) classifier should classify the samples\nsuch that among the samples to which it gave a predict_proba value close to\n0.8, approx. 80% actually belong to the positive class.\n\nLogisticRegression returns well calibrated predictions as it directly\noptimizes log-loss. In contrast, the other methods return biased probabilities,\nwith different biases per method:\n\n* GaussianNaiveBayes tends to push probabilities to 0 or 1 (note the counts in\n the histograms). This is mainly because it makes the assumption that features\n are conditionally independent given the class, which is not the case in this\n dataset which contains 2 redundant features.\n\n* RandomForestClassifier shows the opposite behavior: the histograms show\n peaks at approx. 0.2 and 0.9 probability, while probabilities close to 0 or 1\n are very rare. An explanation for this is given by Niculescu-Mizil and Caruana\n [1]: \"Methods such as bagging and random forests that average predictions from\n a base set of models can have difficulty making predictions near 0 and 1\n because variance in the underlying base models will bias predictions that\n should be near zero or one away from these values. Because predictions are\n restricted to the interval [0,1], errors caused by variance tend to be one-\n sided near zero and one. For example, if a model should predict p = 0 for a\n case, the only way bagging can achieve this is if all bagged trees predict\n zero. If we add noise to the trees that bagging is averaging over, this noise\n will cause some trees to predict values larger than 0 for this case, thus\n moving the average prediction of the bagged ensemble away from 0. We observe\n this effect most strongly with random forests because the base-level trees\n trained with random forests have relatively high variance due to feature\n subsetting.\" As a result, the calibration curve shows a characteristic\n sigmoid shape, indicating that the classifier could trust its \"intuition\"\n more and return probabilities closer to 0 or 1 typically.\n\n* Support Vector Classification (SVC) shows an even more sigmoid curve as\n the RandomForestClassifier, which is typical for maximum-margin methods\n (compare Niculescu-Mizil and Caruana [1]), which focus on hard samples\n that are close to the decision boundary (the support vectors).\n\n.. topic:: References:\n\n .. [1] Predicting Good Probabilities with Supervised Learning,\n A. Niculescu-Mizil & R. Caruana, ICML 2005\n\n"
18+
"\n# Comparison of Calibration of Classifiers\n\n\nWell calibrated classifiers are probabilistic classifiers for which the output\nof the predict_proba method can be directly interpreted as a confidence level.\nFor instance a well calibrated (binary) classifier should classify the samples\nsuch that among the samples to which it gave a predict_proba value close to\n0.8, approx. 80% actually belong to the positive class.\n\nLogisticRegression returns well calibrated predictions as it directly\noptimizes log-loss. In contrast, the other methods return biased probabilities,\nwith different biases per method:\n\n* GaussianNaiveBayes tends to push probabilities to 0 or 1 (note the counts in\n the histograms). This is mainly because it makes the assumption that features\n are conditionally independent given the class, which is not the case in this\n dataset which contains 2 redundant features.\n\n* RandomForestClassifier shows the opposite behavior: the histograms show\n peaks at approx. 0.2 and 0.9 probability, while probabilities close to 0 or 1\n are very rare. An explanation for this is given by Niculescu-Mizil and Caruana\n [1]_: \"Methods such as bagging and random forests that average predictions\n from a base set of models can have difficulty making predictions near 0 and 1\n because variance in the underlying base models will bias predictions that\n should be near zero or one away from these values. Because predictions are\n restricted to the interval [0,1], errors caused by variance tend to be one-\n sided near zero and one. For example, if a model should predict p = 0 for a\n case, the only way bagging can achieve this is if all bagged trees predict\n zero. If we add noise to the trees that bagging is averaging over, this noise\n will cause some trees to predict values larger than 0 for this case, thus\n moving the average prediction of the bagged ensemble away from 0. We observe\n this effect most strongly with random forests because the base-level trees\n trained with random forests have relatively high variance due to feature\n subsetting.\" As a result, the calibration curve shows a characteristic\n sigmoid shape, indicating that the classifier could trust its \"intuition\"\n more and return probabilities closer to 0 or 1 typically.\n\n* Support Vector Classification (SVC) shows an even more sigmoid curve as\n the RandomForestClassifier, which is typical for maximum-margin methods\n (compare Niculescu-Mizil and Caruana [1]_), which focus on hard samples\n that are close to the decision boundary (the support vectors).\n\n.. topic:: References:\n\n .. [1] Predicting Good Probabilities with Supervised Learning,\n A. Niculescu-Mizil & R. Caruana, ICML 2005\n\n"
1919
]
2020
},
2121
{

dev/_downloads/plot_compare_calibration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
* RandomForestClassifier shows the opposite behavior: the histograms show
2222
peaks at approx. 0.2 and 0.9 probability, while probabilities close to 0 or 1
2323
are very rare. An explanation for this is given by Niculescu-Mizil and Caruana
24-
[1]: "Methods such as bagging and random forests that average predictions from
25-
a base set of models can have difficulty making predictions near 0 and 1
24+
[1]_: "Methods such as bagging and random forests that average predictions
25+
from a base set of models can have difficulty making predictions near 0 and 1
2626
because variance in the underlying base models will bias predictions that
2727
should be near zero or one away from these values. Because predictions are
2828
restricted to the interval [0,1], errors caused by variance tend to be one-
@@ -39,7 +39,7 @@
3939
4040
* Support Vector Classification (SVC) shows an even more sigmoid curve as
4141
the RandomForestClassifier, which is typical for maximum-margin methods
42-
(compare Niculescu-Mizil and Caruana [1]), which focus on hard samples
42+
(compare Niculescu-Mizil and Caruana [1]_), which focus on hard samples
4343
that are close to the decision boundary (the support vectors).
4444
4545
.. topic:: References:

dev/_downloads/plot_gradient_boosting_early_stopping.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"Compare fit times with and without early stopping\n----------------------------------------------\n\n"
54+
"Compare fit times with and without early stopping\n-------------------------------------------------\n\n"
5555
]
5656
},
5757
{

dev/_downloads/plot_gradient_boosting_early_stopping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def autolabel(rects, n_estimators):
131131

132132
#######################################################################
133133
# Compare fit times with and without early stopping
134-
# ----------------------------------------------
134+
# -------------------------------------------------
135135

136136
plt.figure(figsize=(9, 5))
137137

dev/_downloads/plot_isolation_forest.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# IsolationForest example\n\n\nAn example using IsolationForest for anomaly detection.\n\nThe IsolationForest 'isolates' observations by randomly selecting a feature\nand then randomly selecting a split value between the maximum and minimum\nvalues of the selected feature.\n\nSince recursive partitioning can be represented by a tree structure, the\nnumber of splittings required to isolate a sample is equivalent to the path\nlength from the root node to the terminating node.\n\nThis path length, averaged over a forest of such random trees, is a measure\nof normality and our decision function.\n\nRandom partitioning produces noticeable shorter paths for anomalies.\nHence, when a forest of random trees collectively produce shorter path lengths\nfor particular samples, they are highly likely to be anomalies.\n\n.. [1] Liu, Fei Tony, Ting, Kai Ming and Zhou, Zhi-Hua. \"Isolation forest.\"\n Data Mining, 2008. ICDM'08. Eighth IEEE International Conference on.\n\n\n"
18+
"\n# IsolationForest example\n\n\nAn example using :class:`sklearn.ensemble.IsolationForest` for anomaly\ndetection.\n\nThe IsolationForest 'isolates' observations by randomly selecting a feature\nand then randomly selecting a split value between the maximum and minimum\nvalues of the selected feature.\n\nSince recursive partitioning can be represented by a tree structure, the\nnumber of splittings required to isolate a sample is equivalent to the path\nlength from the root node to the terminating node.\n\nThis path length, averaged over a forest of such random trees, is a measure\nof normality and our decision function.\n\nRandom partitioning produces noticeable shorter paths for anomalies.\nHence, when a forest of random trees collectively produce shorter path lengths\nfor particular samples, they are highly likely to be anomalies.\n\n\n"
1919
]
2020
},
2121
{

dev/_downloads/plot_isolation_forest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
IsolationForest example
44
==========================================
55
6-
An example using IsolationForest for anomaly detection.
6+
An example using :class:`sklearn.ensemble.IsolationForest` for anomaly
7+
detection.
78
89
The IsolationForest 'isolates' observations by randomly selecting a feature
910
and then randomly selecting a split value between the maximum and minimum
@@ -20,9 +21,6 @@
2021
Hence, when a forest of random trees collectively produce shorter path lengths
2122
for particular samples, they are highly likely to be anomalies.
2223
23-
.. [1] Liu, Fei Tony, Ting, Kai Ming and Zhou, Zhi-Hua. "Isolation forest."
24-
Data Mining, 2008. ICDM'08. Eighth IEEE International Conference on.
25-
2624
"""
2725
print(__doc__)
2826

dev/_downloads/plot_separating_hyperplane_unbalanced.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\nfrom sklearn.datasets import make_blobs\n\n# we create two clusters of random points\nn_samples_1 = 1000\nn_samples_2 = 100\ncenters = [[0.0, 0.0], [2.0, 2.0]]\nclusters_std = [1.5, 0.5]\nX, y = make_blobs(n_samples=[n_samples_1, n_samples_2],\n centers=centers,\n cluster_std=clusters_std,\n random_state=0, shuffle=False)\n\n# fit the model and get the separating hyperplane\nclf = svm.SVC(kernel='linear', C=1.0)\nclf.fit(X, y)\n\n# fit the model and get the separating hyperplane using weighted classes\nwclf = svm.SVC(kernel='linear', class_weight={1: 10})\nwclf.fit(X, y)\n\n# plot separating hyperplanes and samples\nplt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired, edgecolors='k')\nplt.legend()\n\n# plot the decision functions for both classifiers\nax = plt.gca()\nxlim = ax.get_xlim()\nylim = ax.get_ylim()\n\n# create grid to evaluate model\nxx = np.linspace(xlim[0], xlim[1], 30)\nyy = np.linspace(ylim[0], ylim[1], 30)\nYY, XX = np.meshgrid(yy, xx)\nxy = np.vstack([XX.ravel(), YY.ravel()]).T\n\n# get the separating hyperplane\nZ = clf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins\na = ax.contour(XX, YY, Z, colors='k', levels=[0], alpha=0.5, linestyles=['-'])\n\n# get the separating hyperplane for weighted classes\nZ = wclf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins for weighted classes\nb = ax.contour(XX, YY, Z, colors='r', levels=[0], alpha=0.5, linestyles=['-'])\n\nplt.legend([a.collections[0], b.collections[0]], [\"non weighted\", \"weighted\"],\n loc=\"upper right\")\nplt.show()"
29+
"print(__doc__)\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import svm\nfrom sklearn.datasets import make_blobs\n\n# we create two clusters of random points\nn_samples_1 = 1000\nn_samples_2 = 100\ncenters = [[0.0, 0.0], [2.0, 2.0]]\nclusters_std = [1.5, 0.5]\nX, y = make_blobs(n_samples=[n_samples_1, n_samples_2],\n centers=centers,\n cluster_std=clusters_std,\n random_state=0, shuffle=False)\n\n# fit the model and get the separating hyperplane\nclf = svm.SVC(kernel='linear', C=1.0)\nclf.fit(X, y)\n\n# fit the model and get the separating hyperplane using weighted classes\nwclf = svm.SVC(kernel='linear', class_weight={1: 10})\nwclf.fit(X, y)\n\n# plot the samples\nplt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired, edgecolors='k')\n\n# plot the decision functions for both classifiers\nax = plt.gca()\nxlim = ax.get_xlim()\nylim = ax.get_ylim()\n\n# create grid to evaluate model\nxx = np.linspace(xlim[0], xlim[1], 30)\nyy = np.linspace(ylim[0], ylim[1], 30)\nYY, XX = np.meshgrid(yy, xx)\nxy = np.vstack([XX.ravel(), YY.ravel()]).T\n\n# get the separating hyperplane\nZ = clf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins\na = ax.contour(XX, YY, Z, colors='k', levels=[0], alpha=0.5, linestyles=['-'])\n\n# get the separating hyperplane for weighted classes\nZ = wclf.decision_function(xy).reshape(XX.shape)\n\n# plot decision boundary and margins for weighted classes\nb = ax.contour(XX, YY, Z, colors='r', levels=[0], alpha=0.5, linestyles=['-'])\n\nplt.legend([a.collections[0], b.collections[0]], [\"non weighted\", \"weighted\"],\n loc=\"upper right\")\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/plot_separating_hyperplane_unbalanced.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@
4949
wclf = svm.SVC(kernel='linear', class_weight={1: 10})
5050
wclf.fit(X, y)
5151

52-
# plot separating hyperplanes and samples
52+
# plot the samples
5353
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired, edgecolors='k')
54-
plt.legend()
5554

5655
# plot the decision functions for both classifiers
5756
ax = plt.gca()

0 commit comments

Comments
 (0)