Class: EvocCLI::Analyze
Instance Method Summary collapse
- #aggregator_range ⇒ Object
- #all ⇒ Object
- #avg_changes_per_file ⇒ Object
- #avg_commit_size ⇒ Object
- #avg_time_between_commits ⇒ Object
- #commit_size ⇒ Object
- #commits ⇒ Object
- #create_dict ⇒ Object
- #evolution ⇒ Object
- #file_frequency ⇒ Object
- #measure_ranges ⇒ Object
- #measure_values ⇒ Object
- #num_commits ⇒ Object
- #num_unique_files ⇒ Object
- #recommendation_meta ⇒ Object
- #time_span ⇒ Object
- #uniqueness ⇒ Object
Instance Method Details
#aggregator_range ⇒ Object
35 36 37 38 |
# File 'lib/evoc_cli/analyze.rb', line 35 def aggregator_range a = Evoc::Analyze.new() a.aggregator_range end |
#all ⇒ Object
54 55 56 |
# File 'lib/evoc_cli/analyze.rb', line 54 def all Evoc::Analyze.new().all end |
#avg_changes_per_file ⇒ Object
59 60 61 62 63 |
# File 'lib/evoc_cli/analyze.rb', line 59 def avg_changes_per_file a = Evoc::Analyze.new() $stdout.puts __method__ $stdout.puts a.average_changes_per_file end |
#avg_commit_size ⇒ Object
111 112 113 114 115 |
# File 'lib/evoc_cli/analyze.rb', line 111 def avg_commit_size a = Evoc::Analyze.new() $stdout.puts __method__ $stdout.puts a.average_commit_size end |
#avg_time_between_commits ⇒ Object
81 82 83 84 85 86 |
# File 'lib/evoc_cli/analyze.rb', line 81 def avg_time_between_commits a = Evoc::Analyze.new() unit = 'hours' $stdout.puts "#{__method__}_#{unit}" $stdout.puts a.average_time_between_commits(unit: unit) end |
#commit_size ⇒ Object
105 106 107 108 |
# File 'lib/evoc_cli/analyze.rb', line 105 def commit_size a = Evoc::Analyze.new() a.commit_size end |
#commits ⇒ Object
16 17 18 19 |
# File 'lib/evoc_cli/analyze.rb', line 16 def commits a = Evoc::Analyze.new() a.commits end |
#create_dict ⇒ Object
118 119 120 121 |
# File 'lib/evoc_cli/analyze.rb', line 118 def create_dict a = Evoc::Analyze.new() a.create_dict end |
#evolution ⇒ Object
10 11 12 13 |
# File 'lib/evoc_cli/analyze.rb', line 10 def evolution a = Evoc::Analyze.new() a.evolution end |
#file_frequency ⇒ Object
97 98 99 100 |
# File 'lib/evoc_cli/analyze.rb', line 97 def file_frequency a = Evoc::Analyze.new() a.file_frequency end |
#measure_ranges ⇒ Object
29 30 31 32 |
# File 'lib/evoc_cli/analyze.rb', line 29 def measure_ranges a = Evoc::Analyze.new() a.measure_ranges end |
#measure_values ⇒ Object
23 24 25 26 |
# File 'lib/evoc_cli/analyze.rb', line 23 def measure_values a = Evoc::Analyze.new() a.measure_values end |
#num_commits ⇒ Object
66 67 68 69 70 |
# File 'lib/evoc_cli/analyze.rb', line 66 def num_commits a = Evoc::Analyze.new() $stdout.puts __method__ $stdout.puts a.num_commits end |
#num_unique_files ⇒ Object
89 90 91 92 93 |
# File 'lib/evoc_cli/analyze.rb', line 89 def num_unique_files a = Evoc::Analyze.new() $stdout.puts __method__ $stdout.puts a.num_unique_files end |
#recommendation_meta ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/evoc_cli/analyze.rb', line 124 def int i = 1 ARGF.each_line do |line| rec = JSON.parse(line) tx_id = rec["tx_id"] algorithm = rec["algorithm"] ap = rec["average_precision1000"] rank = nil if !ap.nil? if ap > 0 rat = ap.rationalize # the rank is only valid if we obtained a 1 in the numerator if rat.numerator == 1 rank = rat.denominator end end else $stderr.puts "AP was nil for #{tx_id}" end applicable = !rec["rules"].empty? positive_recommendation = !rank.nil? # find the confidence of the correct item expected_outcome = nil confidence_correct = nil rank_one = nil confidence_incorrect = nil discernibility = nil ordered_rec = unique_strongest_consequents(rec["rules"]) if ordered_rec.size > 0 if positive_recommendation expected_outcome = ordered_rec[rank-1][0] confidence_correct = ordered_rec[rank-1][1] else rank_one = ordered_rec[0][0] confidence_incorrect = ordered_rec[0][1] end discernibility = (ordered_rec.group_by{|(_,confidence)| confidence}.size).to_f/ordered_rec.size end # build output hash hash = {tx_id: tx_id, algorithm: algorithm, ap: ap, rank: rank, applicable: applicable, positive_recommendation: positive_recommendation, expected_outcome: expected_outcome, confidence_correct: confidence_correct, rank_one: rank_one, confidence_incorrect: confidence_incorrect, discernibility: discernibility} begin puts hash.to_json rescue JSON::GeneratorError => e $stderr.puts "Failed to convert hash to JSON, error was #{e}\n the hash was \n#{hash}\n\n" next end $stderr.print "#{i} lines processed" i += 1 end end |