@@ -54,10 +54,11 @@ def plot_correlation_correctness(df, metric):
5454 plt .xlabel (metric , color = color )
5555
5656 corr = df [metric ].corr (df ['Correct' ], method = 'kendall' )
57- print ('Kendall corr:' , corr )
57+ print ('Metric: ' + metric + ' ~ Correctness' )
58+ print ('-> Kendall corr:' , corr )
5859
5960 slope , intercept , r_value , p_value , std_err = scipy .stats .linregress (df [metric ], df ['ResponseTime' ])
60- print ('r squared:' , r_value ** 2 )
61+ print ('-> r squared:' , r_value ** 2 )
6162
6263 left , right = plt .xlim ()
6364 ax1 .text (left + ((right - left )/ 40 ), 14 , 'Kendall τ: ' + format (corr , '.2f' ), fontdict = graph_label )
@@ -67,6 +68,7 @@ def plot_correlation_correctness(df, metric):
6768 plt .tight_layout ()
6869
6970 plt .savefig (ROOT_DIR + '/analysis/output/' + metric + '_Correctness.pdf' , dpi = 300 , bbox_inches = 'tight' , pad_inches = 0 )
71+ plt .close (plt .gcf ())
7072
7173
7274def plot_correlation_responsetime (df , metric ):
@@ -87,10 +89,11 @@ def plot_correlation_responsetime(df, metric):
8789 plt .xlabel ("" )
8890
8991 corr = df [metric ].corr (df ['ResponseTime' ], method = 'kendall' )
90- print ('Kendall corr:' , corr )
92+ print ('Metric: ' + metric + ' ~ ResponseTime' )
93+ print ('-> Kendall corr:' , corr )
9194
9295 slope , intercept , r_value , p_value , std_err = scipy .stats .linregress (df [metric ], df ['ResponseTime' ])
93- print ('r squared:' , r_value ** 2 )
96+ print ('-> r squared:' , r_value ** 2 )
9497
9598 left , right = plt .xlim ()
9699 ax1 .text (left + ((right - left )/ 40 ), 8 , 'Kendall τ: ' + format (corr , '.2f' ), fontdict = graph_label )
@@ -100,6 +103,7 @@ def plot_correlation_responsetime(df, metric):
100103 plt .tight_layout ()
101104
102105 plt .savefig (ROOT_DIR + '/analysis/output/' + metric + '_ResponseTime.pdf' , dpi = 300 , bbox_inches = 'tight' , pad_inches = 0 )
106+ plt .close (plt .gcf ())
103107
104108
105109def plot_correlation_subjcomplexity_metrics (df , metric ):
@@ -120,10 +124,11 @@ def plot_correlation_subjcomplexity_metrics(df, metric):
120124 plt .xlabel (metric , color = color )
121125
122126 corr = df [metric ].corr (df ['subj_complexity' ], method = 'kendall' )
123- print ('Kendall corr:' , corr )
127+ print ('Metric: ' + metric + ' ~ SubjComplexity' )
128+ print ('-> Kendall corr:' , corr )
124129
125130 slope , intercept , r_value , p_value , std_err = scipy .stats .linregress (df [metric ], df ['subj_complexity' ])
126- print ('r squared:' , r_value ** 2 )
131+ print ('-> r squared:' , r_value ** 2 )
127132
128133 left , right = plt .xlim ()
129134 ax1 .text (left + ((right - left )/ 40 ), 10 , 'Kendall τ: ' + format (corr , '.2f' ), fontdict = graph_label )
@@ -133,6 +138,7 @@ def plot_correlation_subjcomplexity_metrics(df, metric):
133138 plt .tight_layout ()
134139
135140 plt .savefig (ROOT_DIR + '/analysis/output/SubjComplexity_' + metric + '.pdf' , dpi = 300 , bbox_inches = 'tight' , pad_inches = 0 )
141+ plt .close (plt .gcf ())
136142
137143
138144def plot_correlation_subjcomplexity_responsetime (df ):
@@ -145,10 +151,11 @@ def plot_correlation_subjcomplexity_responsetime(df):
145151 plt .ylim ((0 , 61 ))
146152
147153 corr = df ['subj_complexity' ].corr (df ['ResponseTime' ], method = 'kendall' )
148- print ('Kendall corr:' , corr )
154+ print ('SubjComplexity ~ ResponseTime' )
155+ print ('-> Kendall corr:' , corr )
149156
150157 slope , intercept , r_value , p_value , std_err = scipy .stats .linregress (df ['subj_complexity' ], df ['ResponseTime' ])
151- print ('r squared:' , r_value ** 2 )
158+ print ('-> r squared:' , r_value ** 2 )
152159
153160 plt .ylabel ("Response Time in sec." )
154161 plt .xlabel ("Subjective Complexity Rating" )
@@ -161,6 +168,7 @@ def plot_correlation_subjcomplexity_responsetime(df):
161168 plt .tight_layout ()
162169
163170 plt .savefig (ROOT_DIR + '/analysis/output/SubjComplexity_ResponseTime.pdf' , dpi = 300 , bbox_inches = 'tight' , pad_inches = 0 )
171+ plt .close (plt .gcf ())
164172
165173
166174def plot_correlation_subjcomplexity_correctness (df ):
@@ -173,10 +181,11 @@ def plot_correlation_subjcomplexity_correctness(df):
173181 plt .ylim ((0 , 100 ))
174182
175183 corr = df ['subj_complexity' ].corr (df ['Correct' ], method = 'kendall' )
176- print ('Kendall corr:' , corr )
184+ print ('SubjComplexity ~ Correctness' )
185+ print ('-> Kendall corr:' , corr )
177186
178187 slope , intercept , r_value , p_value , std_err = scipy .stats .linregress (df ['subj_complexity' ], df ['Correct' ])
179- print ('r squared:' , r_value ** 2 )
188+ print ('-> r squared:' , r_value ** 2 )
180189
181190 plt .ylabel ("Correct Responses in %" )
182191 plt .xlabel ("Subjective Complexity Rating" )
@@ -189,6 +198,7 @@ def plot_correlation_subjcomplexity_correctness(df):
189198 plt .tight_layout ()
190199
191200 plt .savefig (ROOT_DIR + '/analysis/output/SubjComplexity_Correctness.pdf' , dpi = 300 , bbox_inches = 'tight' , pad_inches = 0 )
201+ plt .close (plt .gcf ())
192202
193203
194204def select_color_for_metric (metric ):
@@ -231,16 +241,13 @@ def main():
231241 snippet_correctness = snippet_behavioral .groupby ('Snippet' ).mean ()
232242 snippet_correctness ["Correct" ] = snippet_correctness ['Correct' ].apply (convert_to_percent )
233243
234- # create plots for metrics ~ response time
235- plot_correlation_responsetime (snippet_behavioral , "LOC" )
236- plot_correlation_responsetime (snippet_behavioral , "DepDegree" )
237- plot_correlation_responsetime (snippet_behavioral , "McCabe" )
238- plot_correlation_responsetime (snippet_behavioral , "Halstead" )
244+ # create plots for metrics ~ response time & correctness
245+ metrics = ["LOC" , "DepDegree" , "McCabe" , "Halstead" ] # for a small run with the four main representatives
246+ metrics = list (snippet_metrics )[2 :] # for a full run
239247
240- plot_correlation_correctness (snippet_correctness , "LOC" )
241- plot_correlation_correctness (snippet_correctness , "DepDegree" )
242- plot_correlation_correctness (snippet_correctness , "McCabe" )
243- plot_correlation_correctness (snippet_correctness , "Halstead" )
248+ for metric in metrics :
249+ plot_correlation_responsetime (snippet_behavioral , metric )
250+ plot_correlation_correctness (snippet_correctness , metric )
244251
245252 # correlate with behavioral data
246253 print ('\n ##### \n correlating subjective complexity with behavioral data' )
0 commit comments