-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
96 additions
and
35 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
import ast | ||
import configparser | ||
import krippendorff | ||
import pandas as pd | ||
import numpy as np | ||
|
||
config = configparser.ConfigParser() | ||
config.read('config.ini') | ||
def test_krippendorff_alpha(): | ||
df = pd.DataFrame({'rater1': ["N/A", "N/A", "N/A", "N/A", "N/A",3,4,1,2,1,1,3,3,"N/A",3], | ||
'rater2': [1, "N/A", 2, 1, 3,3,4,3,"N/A","N/A","N/A","N/A","N/A","N/A","N/A"], | ||
'rater3': ["N/A", "N/A", 2, 1, 3,4,4,"N/A",2,1,1,3,3,"N/A",4]}) | ||
|
||
# Create an empty list to store the dictionaries | ||
special_sheets_list = [] | ||
data = df.T.values.tolist() | ||
|
||
# Loop over all items in the special sheets dictionary and convert the string values to their appropriate data types using ast.literal_eval() | ||
for key in config['Special_sheets']: | ||
special_sheets_list.append(eval(config['Special_sheets'][key])) | ||
data_tuple = tuple(' '.join(map(str, row)) for row in data) | ||
|
||
reliability_data_str = ( | ||
"3 0.5 0.5 1 0.5 0.25 0.25 0.25 0.25 0.3333 2 0.5 3 2 0.3333", # coder A | ||
"1 0.5 0.3333 0.5 1 0.5 3 1 1 2 3 4 1 1 1", # coder B | ||
"2 0.3333 0.1667 1 2 2 0.2 0.3333 0.3333 0.3333 1 0.3333 3 3 1", # coder C | ||
) | ||
|
||
print(reliability_data_str) | ||
print(data_tuple) | ||
newlistconvert =[[np.nan if (v == "*" or v=="N/A") else v for v in coder.split()] for coder in data_tuple] | ||
reliability_data = [[np.nan if (v == "*" or v=="N/A") else v for v in coder.split()] for coder in reliability_data_str] | ||
|
||
|
||
#assert newlistconvert ==reliability_data | ||
|
||
print("Krippendorff's alpha for nominal metric: ", krippendorff.alpha(reliability_data=reliability_data, | ||
level_of_measurement="nominal")) | ||
#assert (krippendorff.alpha(reliability_data=newlistconvert,level_of_measurement="nominal"))== (krippendorff.alpha(reliability_data=reliability_data, level_of_measurement="nominal")) | ||
|
||
print(special_sheets_list) |