I am probably looking right over it in the documentation, but I wanted to know if there is a way with XGBoost to generate both the prediction and probability for the results? In my case, I am trying to predict a multi-class classifier. it would be great if I could return Medium - 88%.
- Classifier = Medium
- Probability of Prediction = 88%
parameters
params = {
'max_depth': 3,
'objective': 'multi:softmax', # error evaluation for multiclass training
'num_class': 3,
'n_gpus': 0
}
prediction
pred = model.predict(D_test)
results
array([2., 2., 1., ..., 1., 2., 2.], dtype=float32)
User friendly (label encoder)
pred_int = pred.astype(int)
label_encoder.inverse_transform(pred_int[:5])
array(['Medium', 'Medium', 'Low', 'Low', 'Medium'], dtype=object)
EDIT: @Reveille suggested predict_proba. I am not instantiating XGBClassifer(). Should I be? How would I modify my pipeline to use that, if so?
params = {
'max_depth': 3,
'objective': 'multi:softmax', # error evaluation for multiclass training
'num_class': 3,
'n_gpus': 0
}
steps = 20 # The number of training iterations
model = xgb.train(params, D_train, steps)