-
Notifications
You must be signed in to change notification settings - Fork 5
/
kappa.py
31 lines (26 loc) · 826 Bytes
/
kappa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: UTF-8 -*-
from __future__ import print_function
import codecs
import numpy as np
from sklearn.metrics import cohen_kappa_score
import logging
from sklearn import metrics
import pandas as pd
from scipy.stats import fisher_exact
from scipy.stats import spearmanr
fname='../input.txt'
Hlabels=[]
Rlabels=[]
delimiter=','
for line in codecs.open(fname, 'r', 'UTF-8'):
row = line.split(delimiter)
Hlabels.extend(row[1])
Rlabels.extend(row[2])
with codecs.open( '../text_results.txt', 'w', 'UTF-8') as fo:
#for Y in X_Y_dic:
fo.write(str(Rlabels) + '\n')
kappa1 = cohen_kappa_score(Hlabels, Rlabels,weights='linear')
kappa2 = cohen_kappa_score(Hlabels, Rlabels)
corr=spearmanr(Hlabels,Rlabels) # hoping teh wardings go away when I have more data
print(str(corr))
print(kappa1,kappa2)