@@ -196,6 +196,9 @@ def fit(self, X, y):
196
196
elif isinstance (self .datafit , Logistic ):
197
197
self .datafit = Logistic_32 ()
198
198
199
+ if not hasattr (self , "n_features_in_" ):
200
+ self .n_features_in_ = X .shape [1 ]
201
+
199
202
self .classes_ = None
200
203
n_classes_ = 0
201
204
@@ -259,8 +262,10 @@ def fit(self, X, y):
259
262
self .coef_ = np .empty ([len (self .classes_ ), X .shape [1 ]])
260
263
self .intercept_ = 0
261
264
multiclass = OneVsRestClassifier (self ).fit (X , y )
262
- self .coef_ = np .array ([clf .coef_ [0 ] for clf in multiclass .estimators_ ])
263
- self .n_iter_ = max (clf .n_iter_ for clf in multiclass .estimators_ )
265
+ self .coef_ = np .array ([clf .coef_ [0 ]
266
+ for clf in multiclass .estimators_ ])
267
+ self .n_iter_ = max (
268
+ clf .n_iter_ for clf in multiclass .estimators_ )
264
269
elif isinstance (self .datafit , Logistic ):
265
270
self .coef_ = coefs .T
266
271
return self
@@ -905,6 +910,9 @@ def fit(self, X, y):
905
910
self .classes_ = enc .classes_
906
911
n_classes = len (enc .classes_ )
907
912
913
+ if not hasattr (self , "n_features_in_" ):
914
+ self .n_features_in_ = X .shape [1 ]
915
+
908
916
if n_classes <= 2 :
909
917
_ , coefs , _ , self .n_iter_ = self .path (
910
918
X , 2 * y_ind - 1 , np .array ([self .alpha ]), solver = self .solver )
@@ -914,7 +922,8 @@ def fit(self, X, y):
914
922
self .coef_ = np .empty ([n_classes , X .shape [1 ]])
915
923
self .intercept_ = 0.
916
924
multiclass = OneVsRestClassifier (self ).fit (X , y )
917
- self .coef_ = multiclass .coef_
925
+ self .coef_ = np .array ([clf .coef_ [0 ]
926
+ for clf in multiclass .estimators_ ])
918
927
self .n_iter_ = max (clf .n_iter_ for clf in multiclass .estimators_ )
919
928
return self
920
929
@@ -1082,10 +1091,14 @@ def fit(self, X, y):
1082
1091
check_classification_targets (y )
1083
1092
self .classes_ = np .unique (y )
1084
1093
1094
+ if not hasattr (self , "n_features_in_" ):
1095
+ self .n_features_in_ = X .shape [1 ]
1096
+
1085
1097
enc = LabelEncoder ()
1086
1098
y_ind = enc .fit_transform (y )
1087
1099
self .classes_ = enc .classes_
1088
1100
n_classes = len (enc .classes_ )
1101
+
1089
1102
if n_classes <= 2 :
1090
1103
y_ind = 2 * y_ind - 1
1091
1104
is_sparse = issparse (X )
@@ -1114,7 +1127,8 @@ def fit(self, X, y):
1114
1127
self .coef_ = np .empty ([n_classes , X .shape [1 ]])
1115
1128
self .intercept_ = 0.
1116
1129
multiclass = OneVsRestClassifier (self ).fit (X , y )
1117
- self .coef_ = np .array ([clf .coef_ [0 ] for clf in multiclass .estimators_ ])
1130
+ self .coef_ = np .array ([clf .coef_ [0 ]
1131
+ for clf in multiclass .estimators_ ])
1118
1132
self .n_iter_ = max (clf .n_iter_ for clf in multiclass .estimators_ )
1119
1133
return self
1120
1134
0 commit comments