Construct a new unfitted estimator with the same parameters.
Clone does a deep copy of the model in an estimator without actually copying attached data. It returns a new estimator with the same parameters that has not been fitted on any data.
Changed in version 1.3: Delegates to estimator.__sklearn_clone__
if the method exists.
The estimator or group of estimators to be cloned.
If safe is False, clone will fall back to a deep copy on objects that are not estimators. Ignored if estimator.__sklearn_clone__
exists.
The deep copy of the input, an estimator if input is an estimator.
Notes
If the estimator’s random_state
parameter is an integer (or if the estimator doesn’t have a random_state
parameter), an exact clone is returned: the clone and the original estimator will give the exact same results. Otherwise, statistical clone is returned: the clone might return different results from the original estimator. More details can be found in Controlling randomness.
Examples
>>> from sklearn.base import clone >>> from sklearn.linear_model import LogisticRegression >>> X = [[-1, 0], [0, 1], [0, -1], [1, 0]] >>> y = [0, 0, 1, 1] >>> classifier = LogisticRegression().fit(X, y) >>> cloned_classifier = clone(classifier) >>> hasattr(classifier, "classes_") True >>> hasattr(cloned_classifier, "classes_") False >>> classifier is cloned_classifier False
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4