Currently I have a working xgboost XGBClassifier Model trained perfectly with good accuracy.
I have stored the model state (instance of the model) for new prediction on new python file by loading the state.
I am unable to load the labelencoder from the loaded model state to encode the new data.
If I am making use of new LabelEncoder() than my all data are encoded to 0 so I want to make use of the trained data labelEncoder value.
How I can achieve it?
My source code is:
from flask import Flask, request
from sklearn.externals import joblib
app=Flask(__name__)
import pandas as pd
@app.route('/', methods=['POST'])
def hello():
model=joblib.load("Saved_Model.sav")
print(model)
//model is loaded successfully
data=pd.read_json(request.data)
print(data)
col=data.columns
//data also came perfectly
encoder=model.__le__
for i in range(0,len(TrainCols)):
data[col[i]]=encoder.fit_transform(data[col[i]])
prediction=model.predict(data.values)
Please help me to resolve my problem and also how can I get the list of parameters from the Model State?