hncltpcgl
hncltpcgl

Reputation: 21

Prediction Error Xgboost R

I have a train data set named df3.It is a data table.

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 :

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..

Upvotes: 0

Views: 347

Answers (1)

cousin_pete
cousin_pete

Reputation: 578

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.

Upvotes: 0

Related Questions