DOC Removes examples from exceptions docstrings
@@ -49,24 +49,6 @@ class ChangedBehaviorWarning(UserWarning):
class ConvergenceWarning(UserWarning):
"""Custom warning to capture convergence problems
- Examples
- --------
-
- >>> import numpy as np
- >>> import warnings
- >>> from sklearn.cluster import KMeans
- >>> from sklearn.exceptions import ConvergenceWarning
- >>> warnings.simplefilter("always", ConvergenceWarning)
- >>> X = np.asarray([[0, 0],
- ... [0, 1],
- ... [1, 0],
- ... [1, 0]]) # last point is duplicated
- >>> with warnings.catch_warnings(record=True) as w:
- ... km = KMeans(n_clusters=4).fit(X)
- ... print(w[-1].message)
- Number of distinct clusters (3) found smaller than n_clusters (4).
- Possibly due to duplicate points in X.
-
.. versionchanged:: 0.18
Moved from sklearn.utils.
"""
@@ -85,23 +67,6 @@ class DataConversionWarning(UserWarning):
implementation's data-type expectations;
- passes an input whose shape can be interpreted ambiguously.
- Examples
- --------
- >>> from sklearn.utils import validation
- >>> Y = [[1],[2],[3]]
- >>> import warnings
- >>> from sklearn.exceptions import DataConversionWarning
- >>> warnings.simplefilter('always', DataConversionWarning)
- >>> with warnings.catch_warnings(record=True) as w:
- ... try:
- ... # will trigger warning as Y is a column-vector
- ... Y = validation.column_or_1d(Y,warn=True)
- ... except ValueError:
- ... pass
- ... print(w[-1].message)
- A column-vector y was passed when a 1d array was expected. Please change
- the shape of y to (n_samples, ), for example using ravel().
-
.. versionchanged:: 0.18
Moved from sklearn.utils.validation.
"""
@@ -139,27 +104,6 @@ class FitFailedWarning(RuntimeWarning):
and the cross-validation helper function cross_val_score to warn when there
is an error while fitting the estimator.
- Examples
- --------
- >>> from sklearn.model_selection import GridSearchCV
- >>> from sklearn.svm import LinearSVC
- >>> from sklearn.exceptions import FitFailedWarning
- >>> import warnings
- >>> warnings.simplefilter('always', FitFailedWarning)
- >>> gs = GridSearchCV(LinearSVC(), {'C': [-1, -2]}, error_score=0, cv=2)
- >>> X, y = [[1, 2], [3, 4], [5, 6], [7, 8]], [0, 0, 1, 1]
- >>> with warnings.catch_warnings(record=True) as w:
- ... try:
- ... gs.fit(X, y) # This will raise a ValueError since C is < 0
- ... except ValueError:
- ... pass
- ... print(repr(w[-1].message))
- FitFailedWarning('Estimator fit failed. The score on this train-test
- partition for these parameters will be set to 0.000000.
- Details:...Traceback (most recent call last):...ValueError:
- Penalty term must be positive; got (C=-2)...
-
-
.. versionchanged:: 0.18
Moved from sklearn.cross_validation.
"""
