我有以下代码xgb = XGBRegressor(booster='gblinear', reg_lambda=0, learning_rate=0.028) print(xgb)xgb.fit(X_train_sc, y_train)y_pred = xgb.predict(X_test_sc)print("\nFeature Importances:")for item in zip(feature_list_transform, xgb.feature_importances_): print("{1:10.4f} - {0}".format(item[0],item[1]))print("\nR-squared, training set:")print(xgb.score(X_train_sc,y_train))print("R-squared, test set:")print(xgb.score(X_test_sc,y_test))print("\nRoot-mean squared error, from metrics:")mse = mean_squared_error(y_test, y_pred)rmse = np.sqrt(mse)print(rmse)输出是: XGBRegressor(base_score=0.5, booster='gblinear', colsample_bylevel=1, colsample_bytree=1, gamma=0, learning_rate=0.028, max_delta_step=0, max_depth=3, min_child_weight=1, missing=None, n_estimators=100, n_jobs=1, nthread=None, objective='reg:linear', random_state=0, reg_alpha=0, reg_lambda=0, scale_pos_weight=1, seed=None, silent=True, subsample=1) Feature Importances: nan - fertility_rate_log nan - life_expectancy_log nan - avg_supply_of_protein_of_animal_origin_log nan - access_to_improved_sanitation_log nan - access_to_improved_water_sources_log nan - obesity_prevalence_log nan - open_defecation_log nan - access_to_electricity_log nan - cereal_yield_log nan - population_growth_log nan - avg_value_of_food_production_log nan - gross_domestic_product_per_capita_ppp_log nan - net_oda_received_percent_gni_log nan - adult_literacy_rate nan - school_enrollment_rate_female nan - school_enrollment_rate_total nan - caloric_energy_from_cereals_roots_tubers nan - anemia_prevalence nan - political_stability和错误:c:\python36\lib\site-packages\xgboost\sklearn.py:420: RuntimeWarning: 在 true_divide 中遇到无效值 return all_features / all_features.sum()如何修复这个nan并获得系数?最后,该模型运行良好。
添加回答
举报
0/150
提交
取消