U
    !`cv                     @   sR  d Z ddlZddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZmZ ddlmZmZmZ ddlmZ dd	lmZmZmZ dd
lmZ ddlmZmZmZmZ ddlm Z  ddl!m"Z" ddddgZ#d ddZ$d!ddZ%G dd deee	dZ&G dd dee&Z'G dd dee&Z(G dd dee	dZ)G dd deee)Z*G dd deee)Z+dS )"a  
This module implements multioutput regression and classification.

The estimators provided in this module are meta-estimators: they require
a base estimator to be provided in their constructor. The meta-estimator
extends single output estimators to multioutput estimators.
    N)Parallel)ABCMetaabstractmethod   )BaseEstimatorcloneMetaEstimatorMixin)RegressorMixinClassifierMixinis_classifier)cross_val_predict)check_array	check_X_ycheck_random_state)if_delegate_has_method)check_is_fittedhas_fit_parameter_check_fit_params_deprecate_positional_args)check_classification_targets)delayedMultiOutputRegressorMultiOutputClassifierClassifierChainRegressorChainc                 K   s>   t | } |d k	r*| j||fd|i| n| j||f| | S )Nsample_weight)r   fit)	estimatorXyr   
fit_params r!   2lib/python3.8/site-packages/sklearn/multioutput.py_fit_estimator$   s
    r#   Tc                 C   sl   |rt | } |d k	rB|d k	r0| j||||d qh| j|||d n&|d k	r\| j|||d n| || | S )N)classesr   r   )r$   )r   partial_fit)r   r   r   r$   r   
first_timer!   r!   r"   _partial_fit_estimator-   s    
r(   c                   @   sN   e Zd ZeeddddZeddddZddd	Zd
d Z	dd Z
dS )_MultiOutputEstimatorNn_jobsc                C   s   || _ || _d S N)r   r+   selfr   r+   r!   r!   r"   __init__C   s    z_MultiOutputEstimator.__init__r   c                    s   t  dddd\ jdkr(tddk	rDtjdsDtdtd	 tjd
 fddtj	d D _
S )a]  Incrementally fit the model to data.
        Fit a separate model for each output variable.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            Data.

        y : {array-like, sparse matrix} of shape (n_samples, n_outputs)
            Multi-output targets.

        classes : list of ndarray of shape (n_outputs,)
            Each array is unique classes for one output in str/int
            Can be obtained by via
            ``[np.unique(y[:, i]) for i in range(y.shape[1])]``, where y is the
            target matrix of the entire dataset.
            This argument is required for the first call to partial_fit
            and can be omitted in the subsequent calls.
            Note that y doesn't need to contain all labels in `classes`.

        sample_weight : array-like of shape (n_samples,), default=None
            Sample weights. If None, then samples are equally weighted.
            Only supported if the underlying regressor supports sample
            weights.

        Returns
        -------
        self : object
        FTforce_all_finitemulti_outputaccept_sparser   Qy must have at least two dimensions for multi-output regression but has only one.Nr   5Underlying estimator does not support sample weights.estimators_r*   c                 3   sP   | ]H}t tsj| nj d d |f d k	r>| nd V  qd S r,   )r   r(   r6   r   .0ir   r$   r'   r   r.   r   r!   r"   	<genexpr>x   s     z4_MultiOutputEstimator.partial_fit.<locals>.<genexpr>)r   ndim
ValueErrorr   r   hasattrr   r+   rangeshaper6   )r.   r   r   r$   r   r!   r:   r"   r&   I   s     



z!_MultiOutputEstimator.partial_fitc                    s   t jdstdj dddd\ tr<t jdkrNtddk	rjtjd	sjtd
t |t	j
d fddtjd D _S )aH   Fit the model to data.
        Fit a separate model for each output variable.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            Data.

        y : {array-like, sparse matrix} of shape (n_samples, n_outputs)
            Multi-output targets. An indicator matrix turns on multilabel
            estimation.

        sample_weight : array-like of shape (n_samples,), default=None
            Sample weights. If None, then samples are equally weighted.
            Only supported if the underlying regressor supports sample
            weights.

        **fit_params : dict of string -> object
            Parameters passed to the ``estimator.fit`` method of each step.

            .. versionadded:: 0.23

        Returns
        -------
        self : object
        r   z0The base estimator should implement a fit methodFTr0   r   r4   Nr   r5   r*   c                 3   s2   | ]*}t tj d d |f fV  qd S r,   )r   r#   r   r7   r   Zfit_params_validatedr   r.   r   r!   r"   r;      s      z,_MultiOutputEstimator.fit.<locals>.<genexpr>)r>   r   r=   _validate_datar   r   r<   r   r   r   r+   r?   r@   r6   )r.   r   r   r   r    r!   rA   r"   r      s(     




z_MultiOutputEstimator.fitc                    sV   t |  t| jdstdt ddd t| jd fdd| jD }t	|j
S )	a  Predict multi-output variable using a model
         trained for each target variable.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            Data.

        Returns
        -------
        y : {array-like, sparse matrix} of shape (n_samples, n_outputs)
            Multi-output targets predicted across multiple predictors.
            Note: Separate models are generated for each predictor.
        predictz4The base estimator should implement a predict methodFT)r1   r3   r*   c                 3   s   | ]}t |j V  qd S r,   )r   rC   )r8   er   r!   r"   r;      s   z0_MultiOutputEstimator.predict.<locals>.<genexpr>)r   r>   r   r=   r   r   r+   r6   npZasarrayT)r.   r   r   r!   rE   r"   rC      s    z_MultiOutputEstimator.predictc                 C   s   ddiS Nmultioutput_onlyTr!   r.   r!   r!   r"   
_more_tags   s    z _MultiOutputEstimator._more_tags)NN)N)__name__
__module____qualname__r   r   r/   r   r&   r   rC   rK   r!   r!   r!   r"   r)   @   s   6
9r)   )	metaclassc                       s@   e Zd ZdZedd fdd
Zedd	 fdd	Z  ZS )
r   a-  Multi target regression

    This strategy consists of fitting one regressor per target. This is a
    simple strategy for extending regressors that do not natively support
    multi-target regression.

    .. versionadded:: 0.18

    Parameters
    ----------
    estimator : estimator object
        An estimator object implementing :term:`fit` and :term:`predict`.

    n_jobs : int or None, optional (default=None)
        The number of jobs to run in parallel.
        :meth:`fit`, :meth:`predict` and :meth:`partial_fit` (if supported
        by the passed estimator) will be parallelized for each target.

        When individual estimators are fast to train or predict,
        using ``n_jobs > 1`` can result in slower performance due
        to the parallelism overhead.

        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all available processes / threads.
        See :term:`Glossary <n_jobs>` for more details.

        .. versionchanged:: 0.20
           `n_jobs` default changed from 1 to None

    Attributes
    ----------
    estimators_ : list of ``n_output`` estimators
        Estimators used for predictions.

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.datasets import load_linnerud
    >>> from sklearn.multioutput import MultiOutputRegressor
    >>> from sklearn.linear_model import Ridge
    >>> X, y = load_linnerud(return_X_y=True)
    >>> clf = MultiOutputRegressor(Ridge(random_state=123)).fit(X, y)
    >>> clf.predict(X[[0]])
    array([[176..., 35..., 57...]])
    Nr*   c                   s   t  j||d d S Nr*   superr/   r-   	__class__r!   r"   r/     s    zMultiOutputRegressor.__init__r   c                    s   t  j|||d dS )at  Incrementally fit the model to data.
        Fit a separate model for each output variable.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            Data.

        y : {array-like, sparse matrix} of shape (n_samples, n_outputs)
            Multi-output targets.

        sample_weight : array-like of shape (n_samples,), default=None
            Sample weights. If None, then samples are equally weighted.
            Only supported if the underlying regressor supports sample
            weights.

        Returns
        -------
        self : object
        r%   N)rR   r&   )r.   r   r   r   rS   r!   r"   r&     s
      z MultiOutputRegressor.partial_fit)N)	rL   rM   rN   __doc__r   r/   r   r&   __classcell__r!   r!   rS   r"   r      s
   -c                       s\   e Zd ZdZedd fdd
Zd fdd	Zedd	 Zd
d Z	dd Z
dd Z  ZS )r   a  Multi target classification

    This strategy consists of fitting one classifier per target. This is a
    simple strategy for extending classifiers that do not natively support
    multi-target classification

    Parameters
    ----------
    estimator : estimator object
        An estimator object implementing :term:`fit`, :term:`score` and
        :term:`predict_proba`.

    n_jobs : int or None, optional (default=None)
        The number of jobs to run in parallel.
        :meth:`fit`, :meth:`predict` and :meth:`partial_fit` (if supported
        by the passed estimator) will be parallelized for each target.

        When individual estimators are fast to train or predict,
        using ``n_jobs > 1`` can result in slower performance due
        to the parallelism overhead.

        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all available processes / threads.
        See :term:`Glossary <n_jobs>` for more details.

        .. versionchanged:: 0.20
           `n_jobs` default changed from 1 to None

    Attributes
    ----------
    classes_ : ndarray of shape (n_classes,)
        Class labels.

    estimators_ : list of ``n_output`` estimators
        Estimators used for predictions.

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.datasets import make_multilabel_classification
    >>> from sklearn.multioutput import MultiOutputClassifier
    >>> from sklearn.neighbors import KNeighborsClassifier

    >>> X, y = make_multilabel_classification(n_classes=3, random_state=0)
    >>> clf = MultiOutputClassifier(KNeighborsClassifier()).fit(X, y)
    >>> clf.predict(X[-2:])
    array([[1, 1, 0], [1, 1, 1]])
    Nr*   c                   s   t  j||d d S rP   rQ   r-   rS   r!   r"   r/   V  s    zMultiOutputClassifier.__init__c                    s*   t  j|||f| dd | jD | _| S )a  Fit the model to data matrix X and targets Y.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            The input data.
        Y : array-like of shape (n_samples, n_classes)
            The target values.
        sample_weight : array-like of shape (n_samples,), default=None
            Sample weights. If None, then samples are equally weighted.
            Only supported if the underlying classifier supports sample
            weights.
        **fit_params : dict of string -> object
            Parameters passed to the ``estimator.fit`` method of each step.

            .. versionadded:: 0.23

        Returns
        -------
        self : object
        c                 S   s   g | ]
}|j qS r!   classes_r8   r   r!   r!   r"   
<listcomp>q  s     z-MultiOutputClassifier.fit.<locals>.<listcomp>)rR   r   r6   rX   )r.   r   Yr   r    rS   r!   r"   r   Z  s    zMultiOutputClassifier.fitc                 C   s*   t |  tdd | jD s$td| jS )ap  Probability estimates.
        Returns prediction probabilities for each class of each output.

        This method will raise a ``ValueError`` if any of the
        estimators do not have ``predict_proba``.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Data

        Returns
        -------
        p : array of shape (n_samples, n_classes), or a list of n_outputs             such arrays if n_outputs > 1.
            The class probabilities of the input samples. The order of the
            classes corresponds to that in the attribute :term:`classes_`.

            .. versionchanged:: 0.19
                This function now returns a list of arrays where the length of
                the list is ``n_outputs``, and each array is (``n_samples``,
                ``n_classes``) for that particular output.
        c                 S   s   g | ]}t |d qS predict_proba)r>   rY   r!   r!   r"   rZ     s   z7MultiOutputClassifier.predict_proba.<locals>.<listcomp>z8The base estimator should implement predict_proba method)r   allr6   AttributeError_predict_probarJ   r!   r!   r"   r]   t  s    z#MultiOutputClassifier.predict_probac                    s    fdd| j D }|S )Nc                    s   g | ]}|  qS r!   r\   rY   rE   r!   r"   rZ     s     z8MultiOutputClassifier._predict_proba.<locals>.<listcomp>)r6   )r.   r   Zresultsr!   rE   r"   r`     s    
z$MultiOutputClassifier._predict_probac                 C   sj   t |  t| j}|jdkr$td|jd |krHtd||jd | |}t	tj
||kddS )a  Returns the mean accuracy on the given test data and labels.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Test samples

        y : array-like of shape (n_samples, n_outputs)
            True values for X

        Returns
        -------
        scores : float
            accuracy_score of self.predict(X) versus y
        r   zTy must have at least two dimensions for multi target classification but has only onezCThe number of outputs of Y for fit {0} and score {1} should be same)Zaxis)r   lenr6   r<   r=   r@   formatrC   rF   Zmeanr^   )r.   r   r   Z
n_outputs_Zy_predr!   r!   r"   score  s    

 
zMultiOutputClassifier.scorec                 C   s   ddiS )N
_skip_testTr!   rJ   r!   r!   r"   rK     s    z MultiOutputClassifier._more_tags)N)rL   rM   rN   rU   r   r/   r   propertyr]   r`   rc   rK   rV   r!   r!   rS   r"   r   %  s   0
c                   @   s6   e Zd ZeddddddZedd Zdd ZdS )	
_BaseChainN)ordercvrandom_statec                C   s   || _ || _|| _|| _d S r,   )base_estimatorrg   rh   ri   )r.   rj   rg   rh   ri   r!   r!   r"   r/     s    z_BaseChain.__init__c                    sx   j ||ddd\}}t j}t|dd  j _t jtrNt	 j _ jdkrpt	t
|jd  _nNt jtr jdkr||jd  _n$t jtt
|jd krtd fdd	t
|jd D  _ jdkr2|dd jf }t|r"tj||fd
d}| }nt||f}nbt|rlt|jd |jd f}tj||fd
d}n(t|jd |jd f}t||f}~t jD ]\}}|dd j| f }	|j|ddd|jd | f |	f|  jdk	r|t jd k r|jd | }
t j|ddd|
f |	 jd}t|r`t|d|dd|
f< n||dd|
f< q S )a  Fit the model to data matrix X and targets Y.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            The input data.
        Y : array-like of shape (n_samples, n_classes)
            The target values.
        **fit_params : dict of string -> object
            Parameters passed to the `fit` method of each step.

            .. versionadded:: 0.23

        Returns
        -------
        self : object
        T)r2   r3   r3   Nr   Zrandomzinvalid orderc                    s   g | ]}t  jqS r!   )r   rj   )r8   _rJ   r!   r"   rZ     s   z"_BaseChain.fit.<locals>.<listcomp>Zlil)rb   r   )r   rh   )rB   r   ri   r   rg   order_
isinstancetuplerF   Zarrayr?   r@   strZpermutationsortedlistr=   r6   rh   spissparsehstackZtocsrZ
lil_matrixzeros	enumerater   ra   r   rj   Zexpand_dims)r.   r   r[   r    ri   Y_pred_chainX_aug	chain_idxr   r   Zcol_idxZ	cv_resultr!   rJ   r"   r     sZ    




$   z_BaseChain.fitc           	      C   s   t |  t|dd}t|jd t| jf}t| jD ]h\}}|ddd|f }t	|r||dkrl|}qt
||f}nt
||f}|||dd|f< q8t| j}tt| j|| j< |dd|f }|S )aR  Predict on the data matrix X using the ClassifierChain model.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            The input data.

        Returns
        -------
        Y_pred : array-like of shape (n_samples, n_classes)
            The predicted values.

        Trk   r   N)r   r   rF   rv   r@   ra   r6   rw   rs   rt   ru   rC   
empty_likerm   arange)	r.   r   rx   rz   r   previous_predictionsry   	inv_orderZY_predr!   r!   r"   rC     s    
z_BaseChain.predict)rL   rM   rN   r   r/   r   r   rC   r!   r!   r!   r"   rf     s   
Grf   c                       sH   e Zd ZdZ fddZeddd Zeddd Zd	d
 Z  Z	S )r   aL  A multi-label model that arranges binary classifiers into a chain.

    Each model makes a prediction in the order specified by the chain using
    all of the available features provided to the model plus the predictions
    of models that are earlier in the chain.

    Read more in the :ref:`User Guide <classifierchain>`.

    .. versionadded:: 0.19

    Parameters
    ----------
    base_estimator : estimator
        The base estimator from which the classifier chain is built.

    order : array-like of shape (n_outputs,) or 'random', default=None
        If None, the order will be determined by the order of columns in
        the label matrix Y.::

            order = [0, 1, 2, ..., Y.shape[1] - 1]

        The order of the chain can be explicitly set by providing a list of
        integers. For example, for a chain of length 5.::

            order = [1, 3, 2, 4, 0]

        means that the first model in the chain will make predictions for
        column 1 in the Y matrix, the second model will make predictions
        for column 3, etc.

        If order is 'random' a random ordering will be used.

    cv : int, cross-validation generator or an iterable, default=None
        Determines whether to use cross validated predictions or true
        labels for the results of previous estimators in the chain.
        Possible inputs for cv are:

        - None, to use true labels when fitting,
        - integer, to specify the number of folds in a (Stratified)KFold,
        - :term:`CV splitter`,
        - An iterable yielding (train, test) splits as arrays of indices.

    random_state : int, RandomState instance or None, optional (default=None)
        If ``order='random'``, determines random number generation for the
        chain order.
        In addition, it controls the random seed given at each `base_estimator`
        at each chaining iteration. Thus, it is only used when `base_estimator`
        exposes a `random_state`.
        Pass an int for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Attributes
    ----------
    classes_ : list
        A list of arrays of length ``len(estimators_)`` containing the
        class labels for each estimator in the chain.

    estimators_ : list
        A list of clones of base_estimator.

    order_ : list
        The order of labels in the classifier chain.

    Examples
    --------
    >>> from sklearn.datasets import make_multilabel_classification
    >>> from sklearn.linear_model import LogisticRegression
    >>> from sklearn.model_selection import train_test_split
    >>> from sklearn.multioutput import ClassifierChain
    >>> X, Y = make_multilabel_classification(
    ...    n_samples=12, n_classes=3, random_state=0
    ... )
    >>> X_train, X_test, Y_train, Y_test = train_test_split(
    ...    X, Y, random_state=0
    ... )
    >>> base_lr = LogisticRegression(solver='lbfgs', random_state=0)
    >>> chain = ClassifierChain(base_lr, order='random', random_state=0)
    >>> chain.fit(X_train, Y_train).predict(X_test)
    array([[1., 1., 0.],
           [1., 0., 0.],
           [0., 1., 0.]])
    >>> chain.predict_proba(X_test)
    array([[0.8387..., 0.9431..., 0.4576...],
           [0.8878..., 0.3684..., 0.2640...],
           [0.0321..., 0.9935..., 0.0625...]])

    See Also
    --------
    RegressorChain : Equivalent for regression.
    MultioutputClassifier : Classifies each output independently rather than
        chaining.

    References
    ----------
    Jesse Read, Bernhard Pfahringer, Geoff Holmes, Eibe Frank, "Classifier
    Chains for Multi-label Classification", 2009.
    c                    s(   t  || dd t| jD | _| S )aO  Fit the model to data matrix X and targets Y.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            The input data.
        Y : array-like of shape (n_samples, n_classes)
            The target values.

        Returns
        -------
        self : object
        c                 S   s   g | ]\}}|j qS r!   rW   )r8   rz   r   r!   r!   r"   rZ     s   z'ClassifierChain.fit.<locals>.<listcomp>)rR   r   rw   r6   rX   )r.   r   r[   rS   r!   r"   r     s
    zClassifierChain.fitrj   c           
      C   s   t |dd}t|jd t| jf}t|jd t| jf}t| jD ]|\}}|ddd|f }t|rt	||f}nt	||f}|
|dddf |dd|f< |||dd|f< qJt| j}tt| j|| j< |dd|f }	|	S )zPredict probability estimates.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)

        Returns
        -------
        Y_prob : array-like of shape (n_samples, n_classes)
        Trk   r   Nr   )r   rF   rv   r@   ra   r6   rw   rs   rt   ru   r]   rC   r{   rm   r|   )
r.   r   ZY_prob_chainrx   rz   r   r}   ry   r~   ZY_probr!   r!   r"   r]     s    
"zClassifierChain.predict_probac           
      C   s   t |jd t| jf}t |jd t| jf}t| jD ]p\}}|ddd|f }t|rtt||f}nt ||f}|	||dd|f< |
||dd|f< q>t | j}t t| j|| j< |dd|f }	|	S )ad  Evaluate the decision_function of the models in the chain.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)

        Returns
        -------
        Y_decision : array-like of shape (n_samples, n_classes)
            Returns the decision function of the sample for each model
            in the chain.
        r   N)rF   rv   r@   ra   r6   rw   rs   rt   ru   decision_functionrC   r{   rm   r|   )
r.   r   ZY_decision_chainrx   rz   r   r}   ry   r~   Z
Y_decisionr!   r!   r"   r     s    
z!ClassifierChain.decision_functionc                 C   s
   dddS )NT)rd   rI   r!   rJ   r!   r!   r"   rK     s    zClassifierChain._more_tags)
rL   rM   rN   rU   r   r   r]   r   rK   rV   r!   r!   rS   r"   r   .  s   b

c                       s(   e Zd ZdZ fddZdd Z  ZS )r   a:  A multi-label model that arranges regressions into a chain.

    Each model makes a prediction in the order specified by the chain using
    all of the available features provided to the model plus the predictions
    of models that are earlier in the chain.

    Read more in the :ref:`User Guide <regressorchain>`.

    .. versionadded:: 0.20

    Parameters
    ----------
    base_estimator : estimator
        The base estimator from which the classifier chain is built.

    order : array-like of shape (n_outputs,) or 'random', default=None
        If None, the order will be determined by the order of columns in
        the label matrix Y.::

            order = [0, 1, 2, ..., Y.shape[1] - 1]

        The order of the chain can be explicitly set by providing a list of
        integers. For example, for a chain of length 5.::

            order = [1, 3, 2, 4, 0]

        means that the first model in the chain will make predictions for
        column 1 in the Y matrix, the second model will make predictions
        for column 3, etc.

        If order is 'random' a random ordering will be used.

    cv : int, cross-validation generator or an iterable, default=None
        Determines whether to use cross validated predictions or true
        labels for the results of previous estimators in the chain.
        Possible inputs for cv are:

        - None, to use true labels when fitting,
        - integer, to specify the number of folds in a (Stratified)KFold,
        - :term:`CV splitter`,
        - An iterable yielding (train, test) splits as arrays of indices.

    random_state : int, RandomState instance or None, optional (default=None)
        If ``order='random'``, determines random number generation for the
        chain order.
        In addition, it controls the random seed given at each `base_estimator`
        at each chaining iteration. Thus, it is only used when `base_estimator`
        exposes a `random_state`.
        Pass an int for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Attributes
    ----------
    estimators_ : list
        A list of clones of base_estimator.

    order_ : list
        The order of labels in the classifier chain.

    Examples
    --------
    >>> from sklearn.multioutput import RegressorChain
    >>> from sklearn.linear_model import LogisticRegression
    >>> logreg = LogisticRegression(solver='lbfgs',multi_class='multinomial')
    >>> X, Y = [[1, 0], [0, 1], [1, 1]], [[0, 2], [1, 1], [2, 0]]
    >>> chain = RegressorChain(base_estimator=logreg, order=[0, 1]).fit(X, Y)
    >>> chain.predict(X)
    array([[0., 2.],
           [1., 1.],
           [2., 0.]])

    See Also
    --------
    ClassifierChain : Equivalent for classification.
    MultioutputRegressor : Learns each output independently rather than
        chaining.

    c                    s   t  j||f| | S )a  Fit the model to data matrix X and targets Y.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            The input data.
        Y : array-like of shape (n_samples, n_classes)
            The target values.

        **fit_params : dict of string -> object
            Parameters passed to the `fit` method at each step
            of the regressor chain.

            .. versionadded:: 0.23

        Returns
        -------
        self : object
        )rR   r   )r.   r   r[   r    rS   r!   r"   r   6  s    zRegressorChain.fitc                 C   s   ddiS rH   r!   rJ   r!   r!   r"   rK   M  s    zRegressorChain._more_tags)rL   rM   rN   rU   r   rK   rV   r!   r!   rS   r"   r     s   O)N)NNT),rU   ZnumpyrF   Zscipy.sparseZsparsers   Zjoblibr   abcr   r   baser   r   r   r	   r
   r   Zmodel_selectionr   Zutilsr   r   r   Zutils.metaestimatorsr   Zutils.validationr   r   r   r   Zutils.multiclassr   Zutils.fixesr   __all__r#   r(   r)   r   r   rf   r   r   r!   r!   r!   r"   <module>   s@    
	  
 L t 9