KeyError: "None of [Index(['Property_Type', 'Beds', 'Baths', 'Toilets', 'Property_attribute',\n 'State'],\n dtype='object')] are in the [columns]" when using pycaret

Hi, got this error while trying to deploy a model i built with pycaret, any suggestion would be a great help.

Hi @seyirex -

Can you provide a code snippet that demonstrates this behavior? It’s not easy to tell what you are trying to do just by looking at a picture of the error.

Best,
Randy

@seyirex The problem is that in the features dictionary, you are making variables as keys and strings as values. But the problem is that in python, keys must be unique which in your case is not happening i.e. all the feature names mentioned in the error are having multiple repeatable keys that’s why when feature dictionary is called, these features are not included and thus creating error for the streamlit.

Try this instead:
feature = {'Property_Type:Property_Type,
‘Beds’:Beds,
‘Baths’:Baths,
‘Toilets’:Toilets,
‘Property_attribute’:Property_attribute,
‘State’:State
}

Notice, I have changed the position of key and values. You have to change all the variables like this and then it will work out fine. Remember, first strings as key and then variable as value i.e. strings : variable.

I hope it helps,

Best,

Muhammad Ali

1 Like

@alihussainia thanks i would try it out and get back to you.

Brother @randyzwitch and brother @seyirex have a look at app.py of my streamlit based project repo.

@randyzwitch and @seyirex here’s the deployed version of the app.

https://share.streamlit.io/alihussainia/star-ratings-prediction/app.py

@alihussainia the solution worked

Nice app, @alihussainia if only you could make the rating fit a table without scrolling to the right to view the rating but due to the your dataset it might not be visable, i love the fact that one is able to use pycaret and steamlit together makes model deployment easy

Thanks, brother @seyirex. I am glad that you liked the work.