Sha256: 6b64a88eded250412c9396e72a7c0d58368dbcaa1dd4ad51d6151de03ce9707f
Contents?: true
Size: 834 Bytes
Versions: 2
Compression:
Stored size: 834 Bytes
Contents
module OpenTox module Algorithm # Regression algorithms class Regression # Weighted average # @param [Array<TrueClass,FalseClass>] dependent_variables # @param [Array<Float>] weights # @return [Hash] def self.weighted_average dependent_variables:, independent_variables:nil, weights:, query_variables:nil # TODO: prediction_interval weighted_sum = 0.0 sim_sum = 0.0 dependent_variables.each_with_index do |v,i| weighted_sum += weights[i]*dependent_variables[i] sim_sum += weights[i] end if dependent_variables sim_sum == 0 ? prediction = nil : prediction = weighted_sum/sim_sum {:value => prediction, :warnings => ["Weighted average prediction, no prediction interval available."]} end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lazar-1.1.3 | lib/regression.rb |
lazar-1.1.0 | lib/regression.rb |