- Intelligent Projects Using Python
- Santanu Pattanayak
- 327字
- 2021-07-02 14:10:48
Taking class imbalances into account
Class imbalance is a major problem when it comes to classification. The following diagram depicts the class densities of the five severity classes:

As we can see from the preceding chart, nearly 73% of the training data belongs to Class 0, which stands for no diabetic retinopathy condition. So if we happen to label all data points as Class 0, then we would have 73% percent accuracy. This is not desirable in patient heath conditions. We would rather have a test say a patient has a certain heath condition when it doesn't (false positive) than have a test that misses detecting a certain heath condition when it does (false negative). A 73% accuracy may mean nothing if the model learns to classify all points as belonging to Class 0.
Detecting the higher severity classes are more important than doing well on the no severity class. The problem with classification models using the log loss or the cross entropy cost function is that it favors the majority class. This is because the cross entropy error is derived from the maximum likelihood principles which tends to assign higher probability to majority classes. We can do two things:
- Discard data from the classes with more samples or up sample the low frequency classes to keep the distribution of samples among classes uniform.
- In the loss function assigns a weight to the classes in inverse proportion to their densities. This will ensure that the low frequency classes impose a higher penalty on the cost function when the model fails to classify them.
We will work with scheme two since it doesn't involve having to generate more data or throw away existing data. If we take the class weights to be proportional to the inverse of the class frequencies, we get the following class weights:

We will use these weights while training the classification network.
- Cortex-M3 + μC/OS-II嵌入式系統開發入門與應用
- 深入淺出SSD:固態存儲核心技術、原理與實戰
- Learning Stencyl 3.x Game Development Beginner's Guide
- 計算機組裝與維修技術
- 基于Apache Kylin構建大數據分析平臺
- CC2530單片機技術與應用
- Hands-On Motion Graphics with Adobe After Effects CC
- 新編電腦組裝與硬件維修從入門到精通
- Spring Cloud實戰
- STM32自學筆記
- 單片機項目設計教程
- 嵌入式系統設計大學教程(第2版)
- 創客電子:Arduino和Raspberry Pi智能制作項目精選
- 詳解FPGA:人工智能時代的驅動引擎
- Machine Learning Projects for Mobile Applications