How to implement F1 score in LightGBM for multi-class classification in R?

Viewed 126

I am using the LightGBM package in R to create my model. I have already defined a function that calculates macro-F1 (defined as the average of F1s throughout all class predictions). I need to report CV macro-F1, so I would like to embed this score into lgb.cv. Nevertheless, the metric is not available in the package implementation, the only solution that I have seen in R is implemented in a binary classification setting (https://rpubs.com/dalekube/LightGBM-F1-Score-R), and most of the other answers are applied in Python.

My options are:

  1. Implement macro-F1 in lgb.cv, which is what I do not know.
  2. Apply my macro-F1 function to a manual cross-validation function that I have created and apply both to lgb.train (although I think that this might not be as optimized as lgb.cv).
  3. Switch to Python
0 Answers
Related