@@ -145,6 +145,8 @@ def partial_fit(self, X, y, classes=None, sample_weight=None):
145
145
146
146
if first_time and hasattr (self .estimators_ [0 ], "n_features_in_" ):
147
147
self .n_features_in_ = self .estimators_ [0 ].n_features_in_
148
+ if first_time and hasattr (self .estimators_ [0 ], "feature_names_in_" ):
149
+ self .feature_names_in_ = self .estimators_ [0 ].feature_names_in_
148
150
149
151
return self
150
152
@@ -206,6 +208,8 @@ def fit(self, X, y, sample_weight=None, **fit_params):
206
208
207
209
if hasattr (self .estimators_ [0 ], "n_features_in_" ):
208
210
self .n_features_in_ = self .estimators_ [0 ].n_features_in_
211
+ if hasattr (self .estimators_ [0 ], "feature_names_in_" ):
212
+ self .feature_names_in_ = self .estimators_ [0 ].feature_names_in_
209
213
210
214
return self
211
215
@@ -279,6 +283,12 @@ class MultiOutputRegressor(RegressorMixin, _MultiOutputEstimator):
279
283
280
284
.. versionadded:: 0.24
281
285
286
+ feature_names_in_ : ndarray of shape (`n_features_in_`,)
287
+ Names of features seen during :term:`fit`. Only defined if the
288
+ underlying estimators expose such an attribute when fit.
289
+
290
+ .. versionadded:: 1.0
291
+
282
292
Examples
283
293
--------
284
294
>>> import numpy as np
@@ -362,6 +372,12 @@ class MultiOutputClassifier(ClassifierMixin, _MultiOutputEstimator):
362
372
363
373
.. versionadded:: 0.24
364
374
375
+ feature_names_in_ : ndarray of shape (`n_features_in_`,)
376
+ Names of features seen during :term:`fit`. Only defined if the
377
+ underlying estimators expose such an attribute when fit.
378
+
379
+ .. versionadded:: 1.0
380
+
365
381
Examples
366
382
--------
367
383
>>> import numpy as np
@@ -675,6 +691,12 @@ class labels for each estimator in the chain.
675
691
676
692
.. versionadded:: 0.24
677
693
694
+ feature_names_in_ : ndarray of shape (`n_features_in_`,)
695
+ Names of features seen during :term:`fit`. Defined only when `X`
696
+ has feature names that are all strings.
697
+
698
+ .. versionadded:: 1.0
699
+
678
700
Examples
679
701
--------
680
702
>>> from sklearn.datasets import make_multilabel_classification
@@ -773,6 +795,7 @@ def decision_function(self, X):
773
795
Returns the decision function of the sample for each model
774
796
in the chain.
775
797
"""
798
+ X = self ._validate_data (X , accept_sparse = True , reset = False )
776
799
Y_decision_chain = np .zeros ((X .shape [0 ], len (self .estimators_ )))
777
800
Y_pred_chain = np .zeros ((X .shape [0 ], len (self .estimators_ )))
778
801
for chain_idx , estimator in enumerate (self .estimators_ ):
@@ -860,6 +883,12 @@ class RegressorChain(MetaEstimatorMixin, RegressorMixin, _BaseChain):
860
883
861
884
.. versionadded:: 0.24
862
885
886
+ feature_names_in_ : ndarray of shape (`n_features_in_`,)
887
+ Names of features seen during :term:`fit`. Defined only when `X`
888
+ has feature names that are all strings.
889
+
890
+ .. versionadded:: 1.0
891
+
863
892
Examples
864
893
--------
865
894
>>> from sklearn.multioutput import RegressorChain
0 commit comments