import pickle
file_name = "xgb_reg.pkl"
# save
pickle.dump(xgb_model, open(file_name, "wb"))
# load
xgb_model_loaded = pickle.load(open(file_name, "rb"))
# test
ind = 1
test = X_val[ind]
xgb_model_loaded.predict(test)[0] == xgb_model.predict(test)[0]
Out[1]: True