zzd1992/GBDTMO

return predicted value for classification

Closed this issue · 4 comments

Dear @zzd1992

First of all, I have to thank you for all of your supports.

I noticed that the predict method, returns the probability of each class in size of n_class.

def predict(self, x, num_trees=0):
        preds = np.full((len(x), self.out_dim), self.base_score, dtype='float64')
        self.lib.Predict.argtypes = [ctypes.c_void_p, array_2d_double, array_2d_double,
                                     ctypes.c_int, ctypes.c_int]
        self.lib.Predict(self._boostnode, x, preds, len(x), num_trees)
        return preds

Is there any method to return the predicted value?

As with the probability, we can not continue with other metrics of classification to see the performance of the model.

Or how can I return the loss to use it to convert the values?

If you use eval set, it computes and shows the acc of eval set during training.

For test, you can compute acc based on the logits.

This project only implements the core algorithm. So you need to do things on your own. Sorry about this.

Thank you.
I am trying to modify some parts based on my needs.
Is there any way to return the loss function after the training, for instance;

params = {"max_depth": 5, "lr": 0.1, 'loss': b"ce", 'verbose': False}
model = GBDTMulti(LIB, out_dim=3, params=params)
model.set_data((x_train, y_train), (x_test, y_test))
model.train(30)
model.lib['loss']

As I do not have access to gbdtm.so, it is quite difficult for me to understand what is going on there.

The model.train(n) return the best score at the end but I can not extract the value.

Currently, you can compute the best score: first running model.predict(data) to get the predictions and then compute the best score on your own.

I agree that this is inconvenient. As you suggested, I will implement the function to access the best score soon.