Diagram
AttributeError: ‘Simple_Imputer’ object has no attribute ‘fill_value_categorical’ error occurs when Simple_Imputer class does not have an attribute called “fill_value_categorical”. The “fill_value_categorical” attribute was removed in version 0.24 of the scikit-learn library.
How to fix it?
To fix the AttributeError: ‘Simple_Imputer’ object has no attribute ‘fill_value_categorical’ error, use the “fill_value” attribute instead of the “fill_value_categorical” attribute.
from sklearn.impute import SimpleImputer
imputer = SimpleImputer(missing_values="NaN", strategy="mean", fill_value="")
imputer.fit(X_train)
If you are using an older version of the scikit-learn library, you can still use the “fill_value_categorical” attribute, but it is deprecated and will eventually be removed.
Here is a table of the old and new attributes for the SimpleImputer class:
Old attribute | New attribute |
---|---|
fill_value_categorical | fill_value |
I hope this will fix the error.
Related posts
AttributeError: ‘SMOTE’ object has no attribute ‘fit_sample’
AttributeError: ‘RandomUnderSampler’ object has no attribute ‘fit_resample’
AttributeError: ‘Pipeline’ object has no attribute ‘fit_resample’

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.