Suppose I encoded my dataset to create a machine learning model using : -
dataset = pd.read_csv('crop_production.csv')
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
dataset = dataset.apply(le.fit_transform)
And I saved this model as .pkl file.
Now I want to call
t = le_new.fit_transform(['Andaman and Nicobar Islands','NICOBARS',2000,'Kharif','Arecanut',1254])
# Predicting the Test set results
y_pred = regressor.predict([t])
How can I achieve this in flask, So that when I use LabelEconder
it encodes same as of le
Example -
le
encodes t
as 0 427 3 1 2 2026
So le_new
should also encode it like this only to predict accurately