TransWikia.com

How to ensure same encoding pattern?

Data Science Asked by Dishant Kothia on September 2, 2021

I created a XGBRegressor model with certain encoded ‘object’ dtypes in the data. Now if I want to run the model with new set of data which is freshly encoded it’s giving wrong predictions. How to ensure that the new dataset is encoded in the same way as was the train data? Or any other solution to this problem?

2 Answers

You can save the encoding and use them to encode the new data. Only thing to make sure is not to have new data which was not there in saved encoding. You can save them as pickle files if you are using Python.

Answered by Shantha Ekanayake on September 2, 2021

Please try this below link to get to know more about this encoding.

https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OrdinalEncoder.html#sklearn.preprocessing.OrdinalEncoder

also, after looking at this you can understand how to save the encoding.

Answered by Shantha Ekanayake on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP