1

I'm creating a model by doing:

X=merged_total.values
Y=X[:,0]
X=X[:,[1,2,5,7,8,9,10,11,12]]

from xgboost import XGBRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score


X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.125)
# fit model no training data
model = XGBRegressor()
model.fit(X_train, y_train)
# make predictions for test data
y_pred = model.predict(X_test)
model.save_model('Civil.model')

and later in the code, when I try to load and predict Y for X_test doing:

X=keytable.values
Y=X[:,13]
X=X[:,[8,7,6,15,13,14,12,2,0]]



X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.125)
# # fit model no training data
model = XGBRegressor()
model = model.load_model('Civil.model')
model.fit(X_train, y_train)
# # make predictions for test data
y_pred = model.predict(X_test)

I always get the error "AttributeError: 'NoneType' object has no attribute 'predict'/'fit'" What am I doing wrong?

I'm using the github cloned version of XGB on a MacBook Air.

desertnaut
  • 57,590
  • 26
  • 140
  • 166

0 Answers0