I have build a machine learning model using xgboost.XGBClassifier
in python. I am using pickle
to serialize the model right now but would like to have a json file of this model, too. How can I do it?
So, basically I have this code :
from xgboost import XGBClassifier
import pickle
import pandas as pd
# read data
df = pd.read_csv('data.csv', sep='\t')
# features and target :
X = df.drop(columns=['target'],axis=1)
Y = df['target']
# split the data
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.3, random_state=0)
model = XGBClassifier().fit(X_train,Y_train)
pickle_out = open("pickle_file.pkl","wb")
pickle.dump(model, pickle_out)
pickle_out.close()