@@ -30,7 +30,7 @@ def _halfway_points(values):
30
30
"""
31
31
return [(values [i ] + values [i + 1 ]) / 2 for i in range (len (values ) - 1 )]
32
32
33
- class NumericBinarizer (BaseEstimator , TransformerMixin ):
33
+ class NumericBinarizer (TransformerMixin , BaseEstimator ):
34
34
f"""
35
35
Encode numerical features as a one-hot numeric array.
36
36
@@ -212,8 +212,7 @@ def transform(self, X):
212
212
# Check that the input is of the same shape as the one passed
213
213
# during fit.
214
214
if X .shape [1 ] != self .n_features_in_ :
215
- raise ValueError ('Shape of input is different form what was seen'
216
- 'in `fit`' )
215
+ raise ValueError (f"X has { X .shape [1 ]} features, but NumericBinarizer is expecting { self .n_features_in_ } features as input" )
217
216
218
217
# Return a binarization of the input samples based on halfway point splits
219
218
Xb_lists = [[X [:, i ] <= val for val in _halfway_points (self .column_values_ [i ])] for i in range (self .n_features_in_ )]
@@ -243,8 +242,7 @@ def inverse_transform(self, Xt):
243
242
# Check that the input is of the same shape as the one passed
244
243
# during fit.
245
244
if Xt .shape [1 ] != self .n_features_out_ :
246
- raise ValueError ('Shape of input is different from what was seen '
247
- 'in `fit`' )
245
+ raise ValueError (f"X has { Xt .shape [1 ]} features, but NumericBinarizer.inverse_transform is expecting { self .n_features_out_ } features as input" )
248
246
249
247
# Initialize an empty array for inverse transformed data
250
248
X = np .empty ((Xt .shape [0 ], self .n_features_in_ ))
0 commit comments