@@ -408,43 +408,40 @@ it will allow the estimator RNG to vary for each fold.
408
408
illustration purpose: what matters is what we pass to the
409
409
:class: `~sklearn.ensemble.RandomForestClassifier ` estimator.
410
410
411
- |details-start |
412
- **Cloning **
413
- |details-split |
411
+ .. dropdown :: Cloning
412
+
413
+ Another subtle side effect of passing `RandomState ` instances is how
414
+ :func: `~sklearn.base.clone ` will work::
415
+
416
+ >>> from sklearn import clone
417
+ >>> from sklearn.ensemble import RandomForestClassifier
418
+ >>> import numpy as np
419
+
420
+ >>> rng = np.random.RandomState(0)
421
+ >>> a = RandomForestClassifier(random_state=rng)
422
+ >>> b = clone(a)
423
+
424
+ Since a `RandomState ` instance was passed to `a `, `a ` and `b ` are not clones
425
+ in the strict sense, but rather clones in the statistical sense: `a ` and `b `
426
+ will still be different models, even when calling `fit(X, y) ` on the same
427
+ data. Moreover, `a ` and `b ` will influence each-other since they share the
428
+ same internal RNG: calling `a.fit ` will consume `b `'s RNG, and calling
429
+ `b.fit ` will consume `a `'s RNG, since they are the same. This bit is true for
430
+ any estimators that share a `random_state ` parameter; it is not specific to
431
+ clones.
432
+
433
+ If an integer were passed, `a ` and `b ` would be exact clones and they would not
434
+ influence each other.
435
+
436
+ .. warning ::
437
+ Even though :func: `~sklearn.base.clone ` is rarely used in user code, it is
438
+ called pervasively throughout scikit-learn codebase: in particular, most
439
+ meta-estimators that accept non-fitted estimators call
440
+ :func: `~sklearn.base.clone ` internally
441
+ (:class: `~sklearn.model_selection.GridSearchCV `,
442
+ :class: `~sklearn.ensemble.StackingClassifier `,
443
+ :class: `~sklearn.calibration.CalibratedClassifierCV `, etc.).
414
444
415
- Another subtle side effect of passing `RandomState ` instances is how
416
- :func: `~sklearn.base.clone ` will work::
417
-
418
- >>> from sklearn import clone
419
- >>> from sklearn.ensemble import RandomForestClassifier
420
- >>> import numpy as np
421
-
422
- >>> rng = np.random.RandomState(0)
423
- >>> a = RandomForestClassifier(random_state=rng)
424
- >>> b = clone(a)
425
-
426
- Since a `RandomState ` instance was passed to `a `, `a ` and `b ` are not clones
427
- in the strict sense, but rather clones in the statistical sense: `a ` and `b `
428
- will still be different models, even when calling `fit(X, y) ` on the same
429
- data. Moreover, `a ` and `b ` will influence each-other since they share the
430
- same internal RNG: calling `a.fit ` will consume `b `'s RNG, and calling
431
- `b.fit ` will consume `a `'s RNG, since they are the same. This bit is true for
432
- any estimators that share a `random_state ` parameter; it is not specific to
433
- clones.
434
-
435
- If an integer were passed, `a ` and `b ` would be exact clones and they would not
436
- influence each other.
437
-
438
- .. warning ::
439
- Even though :func: `~sklearn.base.clone ` is rarely used in user code, it is
440
- called pervasively throughout scikit-learn codebase: in particular, most
441
- meta-estimators that accept non-fitted estimators call
442
- :func: `~sklearn.base.clone ` internally
443
- (:class: `~sklearn.model_selection.GridSearchCV `,
444
- :class: `~sklearn.ensemble.StackingClassifier `,
445
- :class: `~sklearn.calibration.CalibratedClassifierCV `, etc.).
446
-
447
- |details-end |
448
445
449
446
CV splitters
450
447
............
0 commit comments