`L iyhddlmZddlmZddlmZddlmZddlm Z ddl m Z dZ Gd d eZ y ) )deepcopy) BaseEstimator)NotFittedError)get_tags) available_if)check_is_fittedcfd}|S)zSCheck that final_estimator has `attr`. Used together with `available_if`. c2t|jyNT)getattr estimator)selfattrs \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/frozen/_frozen.pycheckz_estimator_has..checks%)rrs` r_estimator_hasr s  LrcjeZdZdZdZeeddZdZdZ dZ dZ d Z d d Z d Zy )FrozenEstimatoraEstimator that wraps a fitted estimator to prevent re-fitting. This meta-estimator takes an estimator and freezes it, in the sense that calling `fit` on it has no effect. `fit_predict` and `fit_transform` are also disabled. All other methods are delegated to the original estimator and original estimator's attributes are accessible as well. This is particularly useful when you have a fitted or a pre-trained model as a transformer in a pipeline, and you'd like `pipeline.fit` to have no effect on this step. Parameters ---------- estimator : estimator The estimator which is to be kept frozen. See Also -------- None: No similar entry in the scikit-learn documentation. Examples -------- >>> from sklearn.datasets import make_classification >>> from sklearn.frozen import FrozenEstimator >>> from sklearn.linear_model import LogisticRegression >>> X, y = make_classification(random_state=0) >>> clf = LogisticRegression(random_state=0).fit(X, y) >>> frozen_clf = FrozenEstimator(clf) >>> frozen_clf.fit(X, y) # No-op FrozenEstimator(estimator=LogisticRegression(random_state=0)) >>> frozen_clf.predict(X) # Predictions from `clf.predict` array(...) c||_yNr)rrs r__init__zFrozenEstimator.__init__>s "r __getitem__c:|jj|i|S)z__getitem__ is defined in :class:`~sklearn.pipeline.Pipeline` and :class:`~sklearn.compose.ColumnTransformer`. )rr)rargskwargss rrzFrozenEstimator.__getitem__As *t~~))4:6::rcR|dvrt|dt|j|S)N) fit_predict fit_transformz( is not available for frozen estimators.)AttributeErrorr r)rnames r __getattr__zFrozenEstimator.__getattr__Hs1 3 3 D6)Q!RS St~~t,,rc|Srrrs r__sklearn_clone__z!FrozenEstimator.__sklearn_clone__Os rcN t|jy#t$rYywxYw)NTF)r rrr's r__sklearn_is_fitted__z%FrozenEstimator.__sklearn_is_fitted__Rs(  DNN +  s  $$c0t|j|S)aGNo-op. As a frozen estimator, calling `fit` has no effect. Parameters ---------- X : object Ignored. y : object Ignored. *args : tuple Additional positional arguments. Ignored, but present for API compatibility with `self.estimator`. **kwargs : dict Additional keyword arguments. Ignored, but present for API compatibility with `self.estimator`. Returns ------- self : object Returns the instance itself. )r r)rXyrrs rfitzFrozenEstimator.fitYs4 ' rc T|jdd}|||_|r tdy)aZSet the parameters of this estimator. The only valid key here is `estimator`. You cannot set the parameters of the inner estimator. Parameters ---------- **kwargs : dict Estimator parameters. Returns ------- self : FrozenEstimator This estimator. rNzYou cannot set parameters of the inner estimator in a frozen estimator since calling `fit` has no effect. You can use `frozenestimator.estimator.set_params` to set parameters of the inner estimator.)popr ValueError)rrrs r set_paramszFrozenEstimator.set_paramsvs; JJ{D1  &DN   rcd|jiS)ahGet parameters for this estimator. Returns a `{"estimator": estimator}` dict. The parameters of the inner estimator are not included. Parameters ---------- deep : bool, default=True Ignored. Returns ------- params : dict Parameter names mapped to their values. rr)rdeeps r get_paramszFrozenEstimator.get_paramss T^^,,rcPtt|j}d|_|Sr )rrr _skip_test)rtagss r__sklearn_tags__z FrozenEstimator.__sklearn_tags__s!01 rN)T)__name__ __module__ __qualname____doc__rrrrr%r(r*r.r2r5r9rrrrrsN D#./0;1; -:6-$rrN)copyrbaser exceptionsrutilsrutils.metaestimatorsrutils.validationr rrrrrrDs, '/. KmKr