AttributeError: 'ColumnTransformer' object has no attribute '_name_to_fitted_passthrough'

4.8k Views Asked by At

I am predicting the IPL match win probability. While deploying the model using streamlit it show this error:

AttributeError:  'ColumnTransformer' object has no attribute '_name_to_fitted_passthrough'

That's my code:

from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder

trf = ColumnTransformer([('trf',OneHotEncoder(sparse=False,drop='first'), 
['batting_team','bowling_team','city'])],remainder='passthrough')

pipeline code

pipe = Pipeline(steps=[
('step1',trf),
('step2',LogisticRegression(solver='liblinear'))])
2

There are 2 best solutions below

0
Aryan On

See the version of your sklearn in the environment while building and saving the model using

print(sklearn.__version__)

do the same in the environment where you are loading the model using the same.

probably they aren't the same. Hope this helps!

0
Simranjeet Kaur On

Run your whole code/each cell again and then again run streamlit run file.py.