-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from daelsaid/mturk
mturk_extra_measures
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
post_scoring_compiled_csv/vmreact_extra_measures_combined.py
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pandas as pd | ||
import os | ||
import sys | ||
import csv | ||
from glob import glob | ||
import numpy as np | ||
|
||
data_dir='/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/' | ||
compiled='/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/mturk_vmreact_complete_compilation_initiation.csv' | ||
av_typing='/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/typing_test_averages.csv' | ||
trials=['trial1','trial2','trial3','trial4','trial5','listb','trial6','trial7'] | ||
cols=['values.response_latency', 'expressions.trial_recall_word_latency', | ||
'values.recall_firstcharlatency', 'values.recall_lastcharlatency'] | ||
column_titles=['subjid','date'] | ||
|
||
incorrect=pd.read_csv(os.path.join(data_dir,'incorrect_response.csv'),dtype=str) | ||
vmreact_df=pd.read_csv(compiled,dtype='str') | ||
new_compiled=pd.DataFrame(data=df2,dtype=str) | ||
avg_typing_df=pd.read_csv(av_typing,dtype='str') | ||
|
||
vmreact_df['unique_identifier']=vmreact_df['subject']+'_'+vmreact_df['date'] | ||
df2=vmreact_df.merge(avg_typing_df,left_on='unique_identifier',right_on='unique_identifier',how='outer') | ||
|
||
|
||
new_compiled["total_average_repeats"]=new_compiled.loc[:,'listb_#_repeats':'trial7_#_repeats'].astype(float).mean(axis=1) | ||
new_compiled["total_incorrect"]=new_compiled.loc[:,'listb':'trial7'].astype(float).subtract(15,axis=0) | ||
new_compiled[['listb_errors','trial1_errors','trial2_errors','trial3_errors','trial4_errors','trial5_errors','trial6_errors','trial7_errors']]=new_compiled.loc[:,'listb':'trial7'].astype(float).subtract(15,axis=0).abs() | ||
|
||
# for x,y in incorrect.groupby(['subj_id','trial']): | ||
# print x,y.score.value_counts().T | ||
|
||
new_compiled.to_csv('updated_mturk_vmreact_complete_compilation_initiation.csv') | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pandas as pd | ||
import os | ||
import sys | ||
from glob import glob | ||
import numpy as np | ||
|
||
|
||
data_dir='/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/' | ||
|
||
cols=['date','subject', 'trial1','trial2','trial3','trial4','trial5','listb','trial6','trial7','total_learning','corrected_total_learning','learning_rate','proactive_interference','retroactive_interference','forgetting_and_retention'] | ||
trials=['trial1', 'trial2', 'trial3', 'trial4', 'trial5', 'listb', 'trial6', 'trial7'] | ||
|
||
|
||
for compiled_file in glob(os.path.join(data_dir,'mturk_vmreact_complete_compilation_initiation.csv')): | ||
vmreact_compiled=pd.read_csv(compiled_file,dtype=str,index_col=['gender','age_range']) | ||
bysubj=pd.read_csv(compiled_file,dtype='str') | ||
test_df=vmreact_compiled.loc[:,'list_type':'trial7_values.recall_lastcharlatency'] | ||
for t in trials: | ||
for subj,subj_df in vmreact_compiled.groupby(level=[0,1]): | ||
if len(subj_df) >3: | ||
try: | ||
response_latency=subj[0], subj[1],t+'_values.response_latency', round(subj_df[t+'_values.response_latency'].astype(float).mean(axis=0),4),round(subj_df[t+'_values.response_latency'].astype(float).std(axis=0),4),subj_df[t+'_values.response_latency'].count() | ||
initiation=subj[0],subj[1], t+'_values.recall_firstcharlatency', round(subj_df[t+'_values.recall_firstcharlatency'].astype(float).mean(axis=0),4),round(subj_df[t+'_recency'].astype(float).std(axis=0),4),subj_df[t+'_recency'].count() | ||
repeats=subj[0],subj[1],t+'_#_repeats',round(subj_df[t+'_#_repeats'].astype(float).mean(axis=0),4),round(subj_df[t+'_#_repeats'].astype(float).std(axis=0),4),subj_df[t+'_#_repeats'].count() | ||
trials=subj[0],subj[1],t,round(subj_df[t].astype(float).mean(axis=0),4),round(subj_df[t].astype(float).std(axis=0),4),subj_df[t].count() | ||
primacy=subj[0],subj[1],t+'_primacy',round(subj_df[t+'_primacy'].astype(float).mean(axis=0),4),round(subj_df[t+'_primacy'].astype(float).std(axis=0),4),subj_df[t+'_primacy'].count() | ||
recency=subj[0],subj[1],t+'_recency',round(subj_df[t+'_recency'].astype(float).mean(axis=0),4),round(subj_df[t+'_recency'].astype(float).std(axis=0),4),subj_df[t+'_recency'].count() | ||
composite=subj_df.loc[:,'total_learning':'forgetting_and_retention'].astype(float) | ||
composite_vals=composite.mean(axis=0), composite.std(axis=0),composite.count() | ||
comp=composite.mean(axis=0), composite.std(axis=0),composite.count() | ||
# # print comp[2].T | ||
# print repeats | ||
# print response_latency | ||
# print initiation | ||
# print trials | ||
# print primacy | ||
# print recency | ||
except: | ||
continue | ||
#firstcharaverages |
13 changes: 13 additions & 0 deletions
13
post_scoring_compiled_csv/vmreact_typing_latency_by_subject.py
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pandas as pd | ||
from glob import glob | ||
import os | ||
import shutil | ||
import sys | ||
|
||
|
||
final=[] | ||
|
||
for x in glob(os.path.join(data_dir,'filtered_typing_test.csv')): | ||
df=pd.read_csv(x, dtype='str') | ||
for i, val in df.groupby(['subject','date']): | ||
print i[0]+'_'+i[1],i[0],i[1],val['latency'].astype(int).mean() |