0
$\begingroup$
from sklearn.impute import SimpleImputer

fill_values=SimpleImputer(missing_values=0,strategy='mean')

X_train=fill_values.fit(X_train)
X_test=fill_values.fit(X_test)

imp_X_train=fill_values.transform(X_train)
imp_X_test=fill_values.trainsform(X_test)

Gives this error:

TypeError: float() argument must be a string or a number, not 'SimpleImputer'

Where did I go wrong?

$\endgroup$
0
$\begingroup$

If you want to transform a data array, for example, X_train, with a preprocessor like SimpleImputer you should use method .fit_transform.

For example: X_train = fill_values.fit_transform(X_train)

If you use only fit it will return an instance of type SimpleImputer which is your error.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.