`L iZdZddlZddlZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl mZmZddlmZddlmZmZdd lmZdd lmZdd lmZmZdd lmZdd lmZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/m0Z0dddZ1dddZ2GddeeeZ3GddZ4GddZ5GddZ6GddZ7Gd d!e!Z8Gd"d#Z9Gd$d%Z:Gd&d'Z;Gd(d)Z<Gd*d+Z=Gd,d-Z>Gd.d/Z?d0Z@d1ZAd2ZBd3ZCd4ZDy)5z>Base classes for all estimators and various utility functions.N) defaultdict) __version__)config_context get_config)InconsistentVersionWarning)_MetadataRequester_routing_enabled) is_scalar_nan)validate_parameter_constraints) ReprHTMLMixin_HTMLDocumentationLinkMixin)estimator_html_repr) ParamsDict)_SetOutputMixin)ClassifierTags RegressorTagsTags TargetTagsTransformerTagsget_tags) _IS_32BIT)_check_feature_names_in_generate_get_feature_names_out _is_fitted check_arraycheck_is_fittedTsafec~t|dr%tj|s|jSt ||S)aConstruct 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. .. versionchanged:: 1.3 Delegates to `estimator.__sklearn_clone__` if the method exists. Parameters ---------- estimator : {list, tuple, set} of estimator instance or a single estimator instance The estimator or group of estimators to be cloned. safe : bool, default=True If safe is False, clone will fall back to a deep copy on objects that are not estimators. Ignored if `estimator.__sklearn_clone__` exists. Returns ------- estimator : object 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 :ref:`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 __sklearn_clone__r)hasattrinspectisclassr!_clone_parametrized) estimatorrs R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/base.pycloner(,s7by-.wy7Q**,, yt 44c t|}|tur/|jDcic]\}}|t||c}}S|tt t tfvr!||Dcgc]}t||c}St|drt|trV|stj|St|tr tdtdt|dt|d|j}|jd}|jD]\}} t| d||<|d i|} tj|j | _| jd} |D]!}||} | |} | | ust%d |d |t|d r$tj|j&| _| Scc}}wcc}w#t"$rYwxYw) zLDefault implementation of clone. See :func:`sklearn.base.clone` for details.r get_paramszaCannot clone object. You should provide an instance of scikit-learn estimator instead of a class.zCannot clone object 'z' (type zb): it does not seem to be a scikit-learn estimator as it does not implement a 'get_params' method.FdeepzCannot clone object z?, as the constructor either does not set or modifies parameter _sklearn_output_config)typedictitemsr(listtupleset frozensetr" isinstancecopydeepcopy TypeErrorrepr __class__r+_metadata_requestAttributeError RuntimeErrorr.)r&restimator_typekveklassnew_object_paramsnameparam new_object params_setparam1param2s r'r%r%bs)_N3`. Notes ----- All estimators should specify all the parameters that can be set at the class level in their ``__init__`` as explicit keyword arguments (no ``*args`` or ``**kwargs``). Examples -------- >>> import numpy as np >>> from sklearn.base import BaseEstimator >>> class MyEstimator(BaseEstimator): ... def __init__(self, *, param=1): ... self.param = param ... def fit(self, X, y=None): ... self.is_fitted_ = True ... return self ... def predict(self, X): ... return np.full(shape=X.shape[0], fill_value=self.param) >>> estimator = MyEstimator(param=2) >>> estimator.get_params() {'param': 2} >>> X = np.array([[1, 2], [2, 3], [3, 4]]) >>> y = np.array([1, 0, 1]) >>> estimator.fit(X, y).predict(X) array([2, 2, 2]) >>> estimator.set_params(param=3).fit(X, y).predict(X) array([3, 3, 3]) ct|jd|j}|tjurgStj|}|j j Dcgc],}|jdk7r|j|jk7r|.}}|D]-}|j|jk(std|d|dt|Dcgc]}|jc}Scc}wcc}w)z%Get parameter names for the estimatordeprecated_originalselfzpscikit-learn estimators should always specify their parameters in the signature of their __init__ (no varargs). z with constructor z! doesn't follow this convention.) getattr__init__objectr# signature parametersvaluesrFkind VAR_KEYWORDVAR_POSITIONALr?sorted)clsinitinit_signatureprUs r'_get_param_nameszBaseEstimator._get_param_namess s||%:CLLI 6?? "I!**40$..557 vvAFFamm$;    Avv)))" 36~ G z2!qvv233 3s '1C/C4ct}|jD]it|}|rTt|drHt |t s8|j j}|jfd|D||<k|S)ae Get parameters for this estimator. Parameters ---------- deep : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. Returns ------- params : dict Parameter names mapped to their values. r+c38K|]\}}dz|z|fyw)__Nr/).0rAvalkeys r' z+BaseEstimator.get_params..s"JVQC$JNC0Js) r1r_rQr"r7r0r+r2update)rPr-outvalue deep_itemsres @r'r+zBaseEstimator.get_paramss~f((* CD#&E|4Zt=T"--/557  JzJJCH    r)c h |j|}t|jd|j}tj|j j Dcic]\}}||jc}} fd}|Dcgc] }| vs| }} Dcic] }||vs|||}}|j|Dcic]}||| c}t|j D cgc]\}} ||| s|c} }} t|| Scc}}wcc}wcc}wcc}wcc} }w)a Get parameters for this estimator with a specific HTML representation. Parameters ---------- deep : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. Returns ------- params : ParamsDict Parameter names mapped to their values. We return a `ParamsDict` dictionary, which renders a specific HTML representation in table form. r,rOc|vry|tjk(ryt|trt |t |uryt j ||st|r t|syy)z4Finds the parameters that have been set by the user.TF)r#_emptyr7rMr0np array_equalr ) param_name param_valueinit_default_paramss r'is_non_defaultz6BaseEstimator._get_params_html..is_non_defaults!44":.'..@+}5${:KSW#J/T;>>0<1*=>!+.r)) non_default) r+rQrRr#rTrUr2defaultrgr4r) rPr-rh init_funcrFrGrsremaining_params ordered_outrinon_default_lsrrs @r'_get_params_htmlzBaseEstimator._get_params_htmls,"oo4o(DMM+@$--P %// :EE3F3L3L3N $/D%D%--   2.1TTD@S4SDTT3FV4$RU+tSYV V8HID#d)OIJ%0%6%6%8 XkdEN4QVBBK :UVI Ys0'D DD D$)D$ D).D. D. c |s|S|jd}tt}|jD]`\}}|j d\}}}||vr%|j }t d|d|d|d|r ||||<Ot||||||<b|jD]\}} ||jdi| |S) a Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``__`` so that it's possible to update each component of a nested object. Parameters ---------- **params : dict Estimator parameters. Returns ------- self : estimator instance Estimator instance. Tr,rbzInvalid parameter z for estimator z. Valid parameters are: .r/) r+rr1r2 partitionr_ ValueErrorsetattr set_params) rPparams valid_params nested_paramsreridelimsub_keylocal_valid_params sub_paramss r'rzBaseEstimator.set_params=s$KD1 #D)  ,,. *JC"%--"5 C,&%)%:%:%<" (tfE--?,B!E .3 c"7+c5)$) S! * -224 7OC (L  ( ( 6: 6 7 r)ct|SN)r%rPs r'r!zBaseEstimator.__sklearn_clone__is "4((r)c$ddlm}d}|ddd|}|j|}tdj |j }||kDr|dz}d|z}t j||j} t j||ddd j} d || | vr/|d z }t j||ddd j} d } | t| zt|| z kr|d| d z|| dz}|S) Nr)_EstimatorPrettyPrinterT)compactindentindent_at_namen_max_elements_to_showz ^(\s*\S){%d} z[^\n]*\nz...) utils._pprintrpformatlenjoinsplitrematchend) rP N_CHAR_MAXrN_MAX_ELEMENTS_TO_SHOWpprepr_ n_nonblanklimregexleft_lim right_limellipsiss r'__repr__zBaseEstimator.__repr__ls( ;!#%#9   4 /0  "/C#c)Exxu-113Hdd 488:IuXyj11$HHUE$B$K8<<> H#h-'#e*y*@@ix(505)3EE r)cft|ddr td t| }||jj }t|jjdrt|jtS|S#t $r|jj }YjwxYw)N __slots__zSYou cannot use `__slots__` in objects inheriting from `sklearn.base.BaseEstimator`.sklearn.)_sklearn_version) rQr:super __getstate____dict__r8r>r0 __module__ startswithr1r2r)rPstater<s r'rzBaseEstimator.__getstate__s 4d +0   )G(*E} **, : + +J 7 D DL )MM&&(E )s*B #B0/B0cjt|jjdrT|jdd}|tk7r9t j t|jjt| t|-|y#t$r|jj|YywxYw)Nrrzpre-0.18)estimator_namecurrent_sklearn_versionoriginal_sklearn_version)r0rrpoprwarningswarnrr<__name__r __setstate__r>rrg)rPrpickle_versionr<s r'rzBaseEstimator.__setstate__s : + +J 7"YY'9:FN, .'+~~'>'>0;1? ( G  ' ( MM  ' (s;B $B21B2c6tdtddddS)NF)required)r@ target_tagstransformer_tagsregressor_tagsclassifier_tags)rrrs r'__sklearn_tags__zBaseEstimator.__sklearn_tags__s#"E2!   r)c|t|j|jd|jjy)aYValidate types and values of constructor parameters The expected type and values must be defined in the `_parameter_constraints` class attribute, which is a dictionary `param_name: list of constraints`. See the docstring of `validate_parameter_constraints` for a description of the accepted constraints. Fr,) caller_nameN)r _parameter_constraintsr+r<rrs r'_validate_paramszBaseEstimator._validate_paramss0 '  ' ' OOO '// r))T)i)rr __qualname____doc__r _html_repr classmethodr_r+rzrr!rrrrr __classcell__r<s@r'rMrMsS)V%J44<0:Cx*X)2h,(    r)rMc.eZdZdZdZfdZddZxZS)ClassifierMixinaMixin class for all classifiers in scikit-learn. This mixin defines the following functionality: - set estimator type to `"classifier"` through the `estimator_type` tag; - `score` method that default to :func:`~sklearn.metrics.accuracy_score`. - enforce that `fit` requires `y` to be passed through the `requires_y` tag, which is done by setting the classifier type tag. Read more in the :ref:`User Guide `. Examples -------- >>> import numpy as np >>> from sklearn.base import BaseEstimator, ClassifierMixin >>> # Mixin classes should always be on the left-hand side for a correct MRO >>> class MyEstimator(ClassifierMixin, BaseEstimator): ... def __init__(self, *, param=1): ... self.param = param ... def fit(self, X, y=None): ... self.is_fitted_ = True ... return self ... def predict(self, X): ... return np.full(shape=X.shape[0], fill_value=self.param) >>> estimator = MyEstimator(param=1) >>> X = np.array([[1, 2], [2, 3], [3, 4]]) >>> y = np.array([1, 0, 1]) >>> estimator.fit(X, y).predict(X) array([1, 1, 1]) >>> estimator.score(X, y) 0.66... classifiercrt|}d|_t|_d|j _|S)NrT)rrr@rrrrrPtagsr<s r'rz ClassifierMixin.__sklearn_tags__s6w')*-/$(! r)cBddlm}|||j||S)a Return :ref:`accuracy ` on provided data and labels. In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted. Parameters ---------- X : array-like of shape (n_samples, n_features) Test samples. y : array-like of shape (n_samples,) or (n_samples, n_outputs) True labels for `X`. sample_weight : array-like of shape (n_samples,), default=None Sample weights. Returns ------- score : float Mean accuracy of ``self.predict(X)`` w.r.t. `y`. r)accuracy_score sample_weight)metricsrpredict)rPXyrrs r'scorezClassifierMixin.score s0 ,aa NNr)rrrrr_estimator_typerrrrs@r'rrsD#OOr)rc.eZdZdZdZfdZddZxZS)RegressorMixinaMixin class for all regression estimators in scikit-learn. This mixin defines the following functionality: - set estimator type to `"regressor"` through the `estimator_type` tag; - `score` method that default to :func:`~sklearn.metrics.r2_score`. - enforce that `fit` requires `y` to be passed through the `requires_y` tag, which is done by setting the regressor type tag. Read more in the :ref:`User Guide `. Examples -------- >>> import numpy as np >>> from sklearn.base import BaseEstimator, RegressorMixin >>> # Mixin classes should always be on the left-hand side for a correct MRO >>> class MyEstimator(RegressorMixin, BaseEstimator): ... def __init__(self, *, param=1): ... self.param = param ... def fit(self, X, y=None): ... self.is_fitted_ = True ... return self ... def predict(self, X): ... return np.full(shape=X.shape[0], fill_value=self.param) >>> estimator = MyEstimator(param=0) >>> X = np.array([[1, 2], [2, 3], [3, 4]]) >>> y = np.array([-1, 0, 1]) >>> estimator.fit(X, y).predict(X) array([0, 0, 0]) >>> estimator.score(X, y) 0.0 regressorcrt|}d|_t|_d|j _|S)NrT)rrr@rrrrrs r'rzRegressorMixin.__sklearn_tags__Ls5w'))+o$(! r)cFddlm}|j|}||||S)aReturn :ref:`coefficient of determination ` on test data. The coefficient of determination, :math:`R^2`, is defined as :math:`(1 - \frac{u}{v})`, where :math:`u` is the residual sum of squares ``((y_true - y_pred)** 2).sum()`` and :math:`v` is the total sum of squares ``((y_true - y_true.mean()) ** 2).sum()``. The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of `y`, disregarding the input features, would get a :math:`R^2` score of 0.0. Parameters ---------- X : array-like of shape (n_samples, n_features) Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape ``(n_samples, n_samples_fitted)``, where ``n_samples_fitted`` is the number of samples used in the fitting for the estimator. y : array-like of shape (n_samples,) or (n_samples, n_outputs) True values for `X`. sample_weight : array-like of shape (n_samples,), default=None Sample weights. Returns ------- score : float :math:`R^2` of ``self.predict(X)`` w.r.t. `y`. Notes ----- The :math:`R^2` score used when calling ``score`` on a regressor uses ``multioutput='uniform_average'`` from version 0.23 to keep consistent with default value of :func:`~sklearn.metrics.r2_score`. This influences the ``score`` method of all the multioutput regressors (except for :class:`~sklearn.multioutput.MultiOutputRegressor`). r)r2_scorer)rrr)rPrrrry_preds r'rzRegressorMixin.scoreSs$R &a6??r)rrrs@r'rr'sD"O,@r)rc.eZdZdZdZfdZddZxZS) ClusterMixinapMixin class for all cluster estimators in scikit-learn. - set estimator type to `"clusterer"` through the `estimator_type` tag; - `fit_predict` method returning the cluster labels associated to each sample. Examples -------- >>> import numpy as np >>> from sklearn.base import BaseEstimator, ClusterMixin >>> class MyClusterer(ClusterMixin, BaseEstimator): ... def fit(self, X, y=None): ... self.labels_ = np.ones(shape=(len(X),), dtype=np.int64) ... return self >>> X = [[1, 2], [2, 3], [3, 4]] >>> MyClusterer().fit_predict(X) array([1, 1, 1]) clustererclt|}d|_|jg|j_|S)Nr)rrr@rpreserves_dtypers r'rzClusterMixin.__sklearn_tags__s7w'))  ,46D ! ! 1 r)c @|j|fi||jS)a Perform clustering on `X` and returns cluster labels. Parameters ---------- X : array-like of shape (n_samples, n_features) Input data. y : Ignored Not used, present for API consistency by convention. **kwargs : dict Arguments to be passed to ``fit``. .. versionadded:: 1.4 Returns ------- labels : ndarray of shape (n_samples,), dtype=np.int64 Cluster labels. )fitlabels_)rPrrkwargss r' fit_predictzClusterMixin.fit_predicts!0 f||r)rrrrrrrrrrs@r'rrs&"Or)rc2eZdZdZedZdZdZdZy)BiclusterMixina?Mixin class for all bicluster estimators in scikit-learn. This mixin defines the following functionality: - `biclusters_` property that returns the row and column indicators; - `get_indices` method that returns the row and column indices of a bicluster; - `get_shape` method that returns the shape of a bicluster; - `get_submatrix` method that returns the submatrix corresponding to a bicluster. Examples -------- >>> import numpy as np >>> from sklearn.base import BaseEstimator, BiclusterMixin >>> class DummyBiClustering(BiclusterMixin, BaseEstimator): ... def fit(self, X, y=None): ... self.rows_ = np.ones(shape=(1, X.shape[0]), dtype=bool) ... self.columns_ = np.ones(shape=(1, X.shape[1]), dtype=bool) ... return self >>> X = np.array([[1, 1], [2, 1], [1, 0], ... [4, 7], [3, 5], [3, 6]]) >>> bicluster = DummyBiClustering().fit(X) >>> hasattr(bicluster, "biclusters_") True >>> bicluster.get_indices(0) (array([0, 1, 2, 3, 4, 5]), array([0, 1])) c2|j|jfS)z{Convenient way to get row and column indicators together. Returns the ``rows_`` and ``columns_`` members. )rows_columns_rs r' biclusters_zBiclusterMixin.biclusters_s zz4==((r)c|j|}|j|}tj|dtj|dfS)aRow and column indices of the `i`'th bicluster. Only works if ``rows_`` and ``columns_`` attributes exist. Parameters ---------- i : int The index of the cluster. Returns ------- row_ind : ndarray, dtype=np.intp Indices of rows in the dataset that belong to the bicluster. col_ind : ndarray, dtype=np.intp Indices of columns in the dataset that belong to the bicluster. r)rrrnnonzero)rPirowscolumnss r' get_indiceszBiclusterMixin.get_indicessF"zz!}--"zz$"BJJw$7$:::r)cH|j|}td|DS)a-Shape of the `i`'th bicluster. Parameters ---------- i : int The index of the cluster. Returns ------- n_rows : int Number of rows in the bicluster. n_cols : int Number of columns in the bicluster. c32K|]}t|ywr)r)rcrs r'rfz+BiclusterMixin.get_shape..s-SV-s)rr4)rPrindicess r' get_shapezBiclusterMixin.get_shapes% ""1%-W---r)c|t|d}|j|\}}||ddtjf|fS)aReturn the submatrix corresponding to bicluster `i`. Parameters ---------- i : int The index of the cluster. data : array-like of shape (n_samples, n_features) The data. Returns ------- submatrix : ndarray of shape (n_rows, n_cols) The submatrix corresponding to bicluster `i`. Notes ----- Works with sparse matrices. Only works if ``rows_`` and ``columns_`` attributes exist. csr) accept_sparseN)rrrnnewaxis)rPrdatarow_indcol_inds r' get_submatrixzBiclusterMixin.get_submatrixsB*4u5++A.GArzzM*G344r)N) rrrrpropertyrrrrr/r)r'rrs*6));*.&5r)rc*eZdZdZfdZddZxZS)TransformerMixinaMixin class for all transformers in scikit-learn. This mixin defines the following functionality: - a `fit_transform` method that delegates to `fit` and `transform`; - a `set_output` method to output `X` as a specific container type. If :term:`get_feature_names_out` is defined, then :class:`BaseEstimator` will automatically wrap `transform` and `fit_transform` to follow the `set_output` API. See the :ref:`developer_api_set_output` for details. :class:`OneToOneFeatureMixin` and :class:`ClassNamePrefixFeaturesOutMixin` are helpful mixins for defining :term:`get_feature_names_out`. Examples -------- >>> import numpy as np >>> from sklearn.base import BaseEstimator, TransformerMixin >>> class MyTransformer(TransformerMixin, BaseEstimator): ... def __init__(self, *, param=1): ... self.param = param ... def fit(self, X, y=None): ... return self ... def transform(self, X): ... return np.full(shape=len(X), fill_value=self.param) >>> transformer = MyTransformer() >>> X = [[1, 2], [2, 3], [3, 4]] >>> transformer.fit_transform(X) array([1, 1, 1]) cBt|}t|_|Sr)rrrrrs r'rz!TransformerMixin.__sklearn_tags__Bs w') / 1 r)c jtrc|jjd|j}|r2t j d|j jdt|"|j|fi|j|S|j||fi|j|S)a Fit to data, then transform it. Fits transformer to `X` and `y` with optional parameters `fit_params` and returns a transformed version of `X`. Parameters ---------- X : array-like of shape (n_samples, n_features) Input samples. y : array-like of shape (n_samples,) or (n_samples, n_outputs), default=None Target values (None for unsupervised transformations). **fit_params : dict Additional fit parameters. Returns ------- X_new : ndarray array of shape (n_samples, n_features_new) Transformed array. transformmethodr This object (ah) has a `transform` method which consumes metadata, but `fit_transform` does not forward metadata to `transform`. Please implement a custom `fit_transform` method to forward metadata to `transform` as well. Alternatively, you can explicitly do `set_transform_request`and set all values to `False` to disable metadata routed to `transform`, if that's an option.) r get_metadata_routingconsumeskeysrrr<r UserWarningrr)rPrr fit_paramstransform_paramss r' fit_transformzTransformerMixin.fit_transformGsF  #88:CC":??+< D    '(?(?'@AXX   9488A,,66q9 9488Aq/J/99!< >> import numpy as np >>> from sklearn.base import OneToOneFeatureMixin, BaseEstimator >>> class MyEstimator(OneToOneFeatureMixin, BaseEstimator): ... def fit(self, X, y=None): ... self.n_features_in_ = X.shape[1] ... return self >>> X = np.array([[1, 2], [3, 4]]) >>> MyEstimator().fit(X).get_feature_names_out() array(['x0', 'x1'], dtype=object) Nc4t|dt||S)aGet output feature names for transformation. Parameters ---------- input_features : array-like of str or None, default=None Input features. - If `input_features` is `None`, then `feature_names_in_` is used as feature names in. If `feature_names_in_` is not defined, then the following input feature names are generated: `["x0", "x1", ..., "x(n_features_in_ - 1)"]`. - If `input_features` is an array-like, then `input_features` must match `feature_names_in_` if `feature_names_in_` is defined. Returns ------- feature_names_out : ndarray of str objects Same as input features. n_features_in_) attributes)rrrPinput_featuress r'get_feature_names_outz*OneToOneFeatureMixin.get_feature_names_outs. )9:&t^<>> import numpy as np >>> from sklearn.base import ClassNamePrefixFeaturesOutMixin, BaseEstimator >>> class MyEstimator(ClassNamePrefixFeaturesOutMixin, BaseEstimator): ... def fit(self, X, y=None): ... self._n_features_out = X.shape[1] ... return self >>> X = np.array([[1, 2], [3, 4]]) >>> MyEstimator().fit(X).get_feature_names_out() array(['myestimator0', 'myestimator1'], dtype=object) NcJt|dt||j|S)aFGet output feature names for transformation. The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: `["class_name0", "class_name1", "class_name2"]`. Parameters ---------- input_features : array-like of str or None, default=None Only used to validate feature names with the names seen in `fit`. Returns ------- feature_names_out : ndarray of str objects Transformed feature names. _n_features_out)r)rrr%rs r'r z5ClassNamePrefixFeaturesOutMixin.get_feature_names_outs)" /0. $&&~  r)rr!r/r)r'r#r#s 0 r)r#c.eZdZdZdZfdZddZxZS) DensityMixina"Mixin class for all density estimators in scikit-learn. This mixin defines the following functionality: - sets estimator type to `"density_estimator"` through the `estimator_type` tag; - `score` method that default that do no-op. Examples -------- >>> from sklearn.base import DensityMixin >>> class MyEstimator(DensityMixin): ... def fit(self, X, y=None): ... self.is_fitted_ = True ... return self >>> estimator = MyEstimator() >>> hasattr(estimator, "score") True DensityEstimatorc2t|}d|_|S)Ndensity_estimatorrrr@rs r'rzDensityMixin.__sklearn_tags__sw')1 r)cy)a=Return the score of the model on the data `X`. Parameters ---------- X : array-like of shape (n_samples, n_features) Test samples. y : Ignored Not used, present for API consistency by convention. Returns ------- score : float Nr/)rPrrs r'rzDensityMixin.scores r)rrrs@r'r'r's()O  r)r'c.eZdZdZdZfdZddZxZS) OutlierMixinaMixin class for all outlier detection estimators in scikit-learn. This mixin defines the following functionality: - set estimator type to `"outlier_detector"` through the `estimator_type` tag; - `fit_predict` method that default to `fit` and `predict`. Examples -------- >>> import numpy as np >>> from sklearn.base import BaseEstimator, OutlierMixin >>> class MyEstimator(OutlierMixin): ... def fit(self, X, y=None): ... self.is_fitted_ = True ... return self ... def predict(self, X): ... return np.ones(shape=len(X)) >>> estimator = MyEstimator() >>> X = np.array([[1, 2], [2, 3], [3, 4]]) >>> estimator.fit_predict(X) array([1., 1., 1.]) outlier_detectorc2t|}d|_|S)Nr/r+rs r'rzOutlierMixin.__sklearn_tags__+sw')0 r)c trc|jjd|j}|r2t j d|j jdt|j|fi|j|S)a.Perform fit on X and returns labels for X. Returns -1 for outliers and 1 for inliers. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) The input samples. y : Ignored Not used, present for API consistency by convention. **kwargs : dict Arguments to be passed to ``fit``. .. versionadded:: 1.4 Returns ------- y : ndarray of shape (n_samples,) 1 for inliers, -1 for outliers. rrraY) has a `predict` method which consumes metadata, but `fit_predict` does not forward metadata to `predict`. Please implement a custom `fit_predict` method to forward metadata to `predict` as well.Alternatively, you can explicitly do `set_predict_request`and set all values to `False` to disable metadata routed to `predict`, if that's an option.) r rrrrrr<rrrr)rPrrrrs r'rzOutlierMixin.fit_predict0s>  #88:CC  D    '(?(?'@A::  txx$V$,,Q//r)rrrs@r'r.r.s0)O 20r)r.ceZdZdZy)MetaEstimatorMixinaMixin class for all meta estimators in scikit-learn. This mixin is empty, and only exists to indicate that the estimator is a meta-estimator. .. versionchanged:: 1.6 The `_required_parameters` is now removed and is unnecessary since tests are refactored and don't use this anymore. Examples -------- >>> from sklearn.base import MetaEstimatorMixin >>> from sklearn.datasets import load_iris >>> from sklearn.linear_model import LogisticRegression >>> class MyEstimator(MetaEstimatorMixin): ... def __init__(self, *, estimator=None): ... self.estimator = estimator ... def fit(self, X, y=None): ... if self.estimator is None: ... self.estimator_ = LogisticRegression() ... else: ... self.estimator_ = self.estimator ... return self >>> X, y = load_iris(return_X_y=True) >>> estimator = MyEstimator().fit(X, y) >>> estimator.estimator_ LogisticRegression() N)rrrrr/r)r'r3r3esr)r3c"eZdZdZfdZxZS)MultiOutputMixinz2Mixin to mark estimators that support multioutput.cFt|}d|j_|S)NT)rrr multi_outputrs r'rz!MultiOutputMixin.__sklearn_tags__s#w')(,% r)rrrrrrrs@r'r5r5s<r)r5c"eZdZdZfdZxZS)_UnstableArchMixinz=Mark estimators that are non-determinstic on 32bit or PowerPCct|}txs#tjj d|_|S)N)ppcpowerpc)rrrplatformmachinernon_deterministicrs r'rz#_UnstableArchMixin.__sklearn_tags__s=w')!*" h.>.>.@.K.K /  r)r8rs@r'r:r:sGr)r:ct|trOtjdt t j dddtt|dddk(St|jdk(S)amReturn True if the given estimator is (probably) a classifier. Parameters ---------- estimator : object Estimator object to test. Returns ------- out : bool True if estimator is a classifier and False otherwise. Examples -------- >>> from sklearn.base import is_classifier >>> from sklearn.cluster import KMeans >>> from sklearn.svm import SVC, SVR >>> classifier = SVC() >>> regressor = SVR() >>> kmeans = KMeans() >>> is_classifier(classifier) True >>> is_classifier(regressor) False >>> is_classifier(kmeans) False passing a class to rP is deprecated and will be removed in 1.8. Use an instance of the class instead.rNr r7r0rrprintr#stack FutureWarningrQrr@r&s r' is_classifierrJst:)T" !% (:1(=">!?@L L  y"3T:lJJ I  - - ==r)ct|trOtjdt t j dddtt|dddk(St|jdk(S)asReturn True if the given estimator is (probably) a regressor. Parameters ---------- estimator : estimator instance Estimator object to test. Returns ------- out : bool True if estimator is a regressor and False otherwise. Examples -------- >>> from sklearn.base import is_regressor >>> from sklearn.cluster import KMeans >>> from sklearn.svm import SVC, SVR >>> classifier = SVC() >>> regressor = SVR() >>> kmeans = KMeans() >>> is_regressor(classifier) False >>> is_regressor(regressor) True >>> is_regressor(kmeans) False rBrrCrDrNrrErIs r' is_regressorrLst:)T" !% (:1(=">!?@L L  y"3T:kII I  - - <>> from sklearn.base import is_clusterer >>> from sklearn.cluster import KMeans >>> from sklearn.svm import SVC, SVR >>> classifier = SVC() >>> regressor = SVR() >>> kmeans = KMeans() >>> is_clusterer(classifier) False >>> is_clusterer(regressor) False >>> is_clusterer(kmeans) True rBrrCrDrNrrErIs r' is_clustererrNst>)T" !% (:1(=">!?@L L  y"3T:kII I  - - <PPP I  - -1C CCr)cfd}|S)aCDecorator to run the fit methods of estimators within context managers. Parameters ---------- prefer_skip_nested_validation : bool If True, the validation of parameters of inner estimators or functions called during fit will be skipped. This is useful to avoid validating many times the parameters passed by the user from the public facing API. It's also useful to avoid validating parameters that we pass internally to inner functions that are guaranteed to be valid by the test suite. It should be set to True for most estimators, except for those that receive non-validated objects as parameters, such as meta-estimators that are given estimator objects. Returns ------- decorated_fit : method The decorated fit method. cFtjfd}|S)Nctd}jdk(xr t|}|s|s|jt xs|5|g|i|cdddS#1swYyxYw)Nskip_parameter_validation partial_fit)rT)rrrrr)r&argsrglobal_skip_validationpartial_fit_and_fitted fit_methodprefer_skip_nested_validations r'wrapperz0_fit_context..decorator..wrapperDs~%/\2M%N "##}4NI9N #*2H**,1K5K > ")=d=f=  > > >s  A%%A.) functoolswraps)rYr[rZs` r' decoratorz_fit_context..decoratorCs%  $ > % >$r)r/)rZr^s` r' _fit_contextr_+s0, r))Err8r\r#r>rr collectionsrnumpyrnrr_configrr exceptionsrutils._metadata_requestsr r utils._missingr utils._param_validationr utils._repr_html.baser rutils._repr_html.estimatorrutils._repr_html.paramsrutils._set_outputr utils._tagsrrrrrr utils.fixesrutils.validationrrrrrr(r%rMrrrrr rr#r'r.r3r5r:rJrLrNrPr_r/r)r'rns2D   #/2J)CM;/.#"35l,07t M#>@R D FOFORX@X@v66rc5c5L`=`=F+=+=\- - `+ + \R0R0j>%>P%=P'=TD2.r)