简体   繁体   English

预测误差Xgboost R

[英]Prediction Error Xgboost R

I have a train data set named df3.It is a data table. 我有一个名为df3的火车数据集,它是一个数据表。

I convert it to sparse matrix as follows : 我将其转换为稀疏矩阵,如下所示:

sparse_matrix9 = sparse.model.matrix(ind_cco_fin_ult1~canal_entrada + 
                                   nomprov +
                                   sexo +
                                   ind_empleado +
                                   indext + age + fark + ind_actividad_cliente  
                                 ,data = df3)

And I modelled it with xgboost : 我用xgboost建模:

bst10_X <- xgboost(data = sparse_matrix9, label = output, max_depth = 15,
            eta = 0.03, nthread = 2, nrounds = 550,prediction=TRUE, eval_metric = "auc",objective = "binary:logistic")

#train-auc:0.881950+0.000475    test-auc:0.819496+0.001057

After that I want to predict test data set. 之后,我要预测测试数据集。 First I chosed my variables and make them a data frame : 首先,我选择了变量并将它们设为数据框:

test4<-as.data.frame(
       test3$canal_entrada,
       test3$nomprov,
       test3$sexo,
       test3$ind_empleado,
       test3$indext,
       test3$age,
       test3$fark,
       test3$ind_actividad_cliente
  )

And After that I want convert it to sparse matrix : 然后,我想将其转换为稀疏矩阵:

sparse_matrix_test = xgb.DMatrix(data.matrix(test4))

And predict test data set values : 并预测测试数据集的值:

res <- predict(bst10_X, newdata = sparse_matrix_test)

But it gives me only one unique value on prediction : 但这给了我一个唯一的预测价值:

unique(res)
0.00113265

Why it gives me only one value? 为什么它只给我一个价值? Where am I wrong ? 我哪里错了? How can I predict test data set using trained model ? 如何使用训练有素的模型预测测试数据集?

Thank you.. 谢谢..

If you provide a small dataset for which test and train are drawn then it would help. 如果您提供一个用于测试和训练的小型数据集,则将有所帮助。 Your problem could be in the code or it could be in the data. 您的问题可能出在代码中,也可能出在数据中。 What happens if you first develop your model with some non-sparse data. 如果您首先使用一些非稀疏数据开发模型,会发生什么情况。 If this model runs OK then you may get a clue. 如果此模型运行正常,则可能会提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM