LightGBMRegressorで特徴量の重要度を調べるには
feature_importances_
で重要度を得ることが出来る。
ランダムシャッフル法でRMSEの値が最小になった
特徴量の組み合わせでモデルを作り
特徴量の重要度を出してみた。
先行偏差値で一番重要度が高いのは内枠隣の馬の先行偏差値の重要度292と出ました.
ホントにそうなのか? 重要度の計算方法が良く分からないので、
やっぱりRMSEの値で特徴量を選択した方が良い感じがする。
best_original=['classsa','j_mae_mean','jflag','jockeycode','kato','kmae','kyorisa','noslope','ownercode','soto_mae','soto_tou','tou','trainercode','uchi_mae','umaban','z_ato_mean','z_mae_mean']
X = pd.get_dummies(df[best_original])
y = df['mae']
z = df['ato']
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.2,random_state=2)
model = lgb.LGBMRegressor(learning_rate=0.1,objective='regression',metrics='rmse',max_depth=12,num_leaves=25)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
mse = mean_squared_error(y_test,y_pred)
best_rmse = np.sqrt(mse)
print('best start_RMSE = '+str(best_rmse))
# 特徴量重要度の算出 (データフレームで取得)
#LGBMRegressorのattributeはfeature_importances_ feature_name_
# Feature Importance
fti = model.feature_importances_
for num in range(0,17):
print('\t{0:12s} : {1:>12.0f}'.format(best_original[num], fti[num]))
「AI競馬」私も序章で出ています。