xgboost4j 中的 train 方法要求接收 dmatrix 参数,怎么将 dataframe 格式转成 dmatrix 啊
1
liangzulin 2019-04-28 16:26:55 +08:00
DataFrame ?你确定说的是 DataFrame 吗?这是 xgboost python 里边的 API 吧。
spark 在 JAVA 里边是 Dataset<> 如果是 pandas DataFrame 的话,转成 DMatrix 是这么转的: df = pd.read_csv('some_data.csv') X_train_df = df[['col_x1', 'col_x2', 'col_x3', 'col_x4']] y_train_df = df[['col_y']] dtrain = xgb.DMatrix(X_train_df, label=y_train_df) |