Sha256: 2dd0ee5b66160e50855b96ca88c2f9e457098acb72a821390970ad5f29163051
Contents?: true
Size: 749 Bytes
Versions: 1
Compression:
Stored size: 749 Bytes
Contents
module OpenTox module Algorithm class Classification def self.weighted_majority_vote dependent_variables:, independent_variables:nil, weights:, query_variables: class_weights = {} dependent_variables.each_with_index do |v,i| class_weights[v] ||= [] class_weights[v] << weights[i] unless v.nil? end probabilities = {} class_weights.each do |a,w| probabilities[a] = w.sum/weights.sum end probabilities = probabilities.collect{|a,p| [a,weights.max*p]}.to_h p_max = probabilities.collect{|a,p| p}.max prediction = probabilities.key(p_max) {:value => prediction,:probabilities => probabilities} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lazar-1.0.0 | lib/classification.rb |