# focal loss function help

I am working on a relation extraction and classification problem. The data is in the form of text files. The data is imbalanced. I want to use focal loss function to address class imbalance problem in the data. My question is: Can focal loss be utilized for extraction and classification task to increase the accuracy? Focal loss has been applied on object detection task and for image classification task. The link is below. I want to use this on text classification task.

https://shaoanlu.wordpress.com/2017/08/16/applying-focal-loss-on-cats-vs-dogs-classification-task/

http://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf

## 1 Answer

From Focal Loss for Dense Object Detection paper, focal loss is defined as:

$$FL(p_t) = −(1 − p_t)^γ log(p_t)$$

It is a generalized formation of a loss function that can be directly implemented for any classification problem, including text classification.

Focal loss function is designed for problems with 1:1000 training imbalance. Does your data actually have that much imbalance? If not, you can use much simpler methods (i.e., resampling).