에러
XGBRegression 모델링 에서 발생
UserWarning: Scoring failed. The score on this train-test partition for these parameters will be set to nan. Details:
증상:
nan 으로 나옴
def regression_model(model):
scores = cross_val_score(model, X_train_std, y_train, scoring='neg_mean_squared_error', cv=kfold)
# scores = cross_val_score(model, X, y, scoring='mean_squared_error', cv=kfold)
rmse = (-scores)**0.5
return rmse.mean()
from xgboost import XGBRegressor
from sklearn.model_selection import cross_val_score
regression_model(XGBRegressor(booster='gblinear'))
해결
위 코드 실행 전에 X에 대해서 표준화를 반드시 할 것!!!!
# 데이터 표준화 X 에 대해서만!!!
from sklearn.preprocessing import StandardScaler
std_scale = StandardScaler()
std_scale.fit(X_train)
X_train_std = std_scale.transform(X_train)
X_test_std = std_scale.transform(X_test)