Skip to content

Commit

Permalink
GBM - styling
Browse files Browse the repository at this point in the history
  • Loading branch information
asaf schers committed Dec 2, 2017
1 parent c71c7e8 commit 36dd76e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/scoruby/models/gbm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class Gbm
CONST_XPATH = '//Target/@rescaleConstant'

def initialize(xml)
@decision_trees = xml.xpath(GBM_FOREST_XPATH).collect {|xml_tree|
@decision_trees = xml.xpath(GBM_FOREST_XPATH).map do |xml_tree|
DecisionTree.new(xml_tree)
}
@const = Float(xml.xpath(CONST_XPATH).to_s)
end
@const = Float(xml.xpath(CONST_XPATH).to_s)
end

def tree_count
Expand All @@ -22,11 +22,11 @@ def tree_count

def score(features)
formatted_features = Features.new(features).formatted
x = @decision_trees.map {|dt|
score = dt.decide(formatted_features).score
score.to_s.to_f
}.reduce(:+) + @const
Math.exp(x) / (1 + Math.exp(x))
scores = @decision_trees.map do |dt|
dt.decide(formatted_features).score.to_s.to_f
end
sum = scores.reduce(:+) + @const
Math.exp(sum) / (1 + Math.exp(sum))
end
end
end
Expand Down

0 comments on commit 36dd76e

Please sign in to comment.