DOC Avoid training/predicting on random dataset in the tutorial
@@ -322,12 +322,9 @@ via the :term:`set_params()<set_params>` method. Calling ``fit()`` more than
once will overwrite what was learned by any previous ``fit()``::
>>> import numpy as np
+ >>> from sklearn.datasets import load_iris
>>> from sklearn.svm import SVC
-
- >>> rng = np.random.RandomState(0)
- >>> X = rng.rand(100, 10)
- >>> y = rng.binomial(1, 0.5, 100)
- >>> X_test = rng.rand(5, 10)
+ >>> X, y = load_iris(return_X_y=True)
>>> clf = SVC()
>>> clf.set_params(kernel='linear').fit(X, y) # doctest: +NORMALIZE_WHITESPACE
@@ -335,16 +332,16 @@ once will overwrite what was learned by any previous ``fit()``::
decision_function_shape='ovr', degree=3, gamma='auto_deprecated',
kernel='linear', max_iter=-1, probability=False, random_state=None,
shrinking=True, tol=0.001, verbose=False)
- >>> clf.predict(X_test)
- array([1, 0, 1, 1, 0])
+ >>> clf.predict(X[:5])
+ array([0, 0, 0, 0, 0])
>>> clf.set_params(kernel='rbf', gamma='scale').fit(X, y) # doctest: +NORMALIZE_WHITESPACE
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape='ovr', degree=3, gamma='scale', kernel='rbf',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
- >>> clf.predict(X_test)
- array([0, 0, 0, 1, 0])
+ >>> clf.predict(X[:5])
+ array([0, 0, 0, 0, 0])
Here, the default kernel ``rbf`` is first changed to ``linear`` via
:func:`SVC.set_params()<sklearn.svm.SVC.set_params>` after the estimator has
