Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MCC functions for ML

NotificationsYou must be signed in to change notification settings

vlainic/matthews-correlation-coefficient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MCC function for ML

Here I would like to share my implementation of Matthews Correlation Coefficient (MCC) for various situations.

Inspiration fromKaggle kernel by Michal on "Best loss function for F1-score metric".

Intro on MCC

I encountered MCC while search for the"best multi-class classification metric".

Wikipedia has very nice explanation of MCC, while atstats.stackexchange you can find a very interesting discussion on the topic. Multi-class MCC is often called "R_K statistics" so I foundthe whole page devoted to it.

The most useful expression for computation was Eq.(8) from the original article byGorodkin:

where N is the number of examples, \tilde{C}_k is the kth row of the confusion matrix C, \hat{C}_l the lth column of C, C^T is C transposed and Tr(C) is the trace of C.

Note: if you only need MCC value to be computed usesklearn.metrics.matthews_corrcoef !!!

binary_mcc_loss.py

Function that can be used as loss function for Keras training in the binary classification case.

multi_mcc_loss.py

Function that can be used as loss function for Keras training in the multi-class classification case.

plot_mcc_vs_tresh.py

Following the practice of plotting precision/recall vs tresholds, I wanted to see how MCC behaves.


[8]ページ先頭

©2009-2025 Movatter.jp