lib/eps/evaluators/lightgbm.rb in eps-0.3.5 vs lib/eps/evaluators/lightgbm.rb in eps-0.3.6
- old
+ new
@@ -17,18 +17,12 @@
rows = data.map(&:to_h)
# sparse matrix
@text_features.each do |k, v|
encoder = TextEncoder.new(**v)
+ counts = encoder.transform(data.columns[k])
- values = data.columns.delete(k)
- counts = encoder.transform(values)
-
- encoder.vocabulary.each do |word|
- data.columns[[k, word]] = [0] * values.size
- end
-
counts.each_with_index do |xc, i|
row = rows[i]
row.delete(k)
xc.each do |word, count|
row[[k, word]] = count
@@ -50,10 +44,10 @@
tree_scores = []
num_trees = @trees.size / @labels.size
@trees.each_slice(num_trees).each do |trees|
tree_scores << sum_trees(rows, trees)
end
- data.size.times.map do |i|
+ rows.size.times.map do |i|
v = tree_scores.map { |s| s[i] }
if probabilities
exp = v.map { |vi| Math.exp(vi) }
sum = exp.sum
@labels.zip(exp.map { |e| e / sum }).to_h