nimbus 0.8 → 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,10 @@ module Nimbus
16
16
  self.mean_squared_error(ids, value_table, mean) / ids.size
17
17
  end
18
18
 
19
+ def squared_difference(x,y)
20
+ 0.0 + (x-y)**2
21
+ end
22
+
19
23
  end
20
24
 
21
25
  end
data/lib/nimbus/tree.rb CHANGED
@@ -57,12 +57,12 @@ module Nimbus
57
57
 
58
58
  def generalization_error_from_oob(oob_ids)
59
59
  return nil if (@structure.nil? || @individuals.nil? || @id_to_fenotype.nil?)
60
- oob_y_hat = Nimbus::LossFunctions.average(oob_ids, @id_to_fenotype)
61
- oob_predictions = {}
60
+ oob_errors = {}
62
61
  oob_ids.each do |oobi|
63
- oob_predictions[oobi] = Tree.traverse @structure, individuals[oobi].snp_list
62
+ oob_prediction = Tree.traverse @structure, individuals[oobi].snp_list
63
+ oob_errors[oobi] = Nimbus::LossFunctions.squared_difference oob_prediction, @id_to_fenotype[oobi]
64
64
  end
65
- @generalization_error = Nimbus::LossFunctions.quadratic_loss oob_ids, oob_predictions, oob_y_hat
65
+ @generalization_error = Nimbus::LossFunctions.average oob_ids, oob_errors
66
66
  end
67
67
 
68
68
  def estimate_importances(oob_ids)
@@ -74,7 +74,7 @@ module Nimbus
74
74
  permutated_snp_error = 0.0
75
75
  oob_ids.each_with_index {|oobi, index|
76
76
  permutated_prediction = traverse_with_permutation @structure, individuals[oobi].snp_list, current_snp, individuals[shuffled_ids[index]].snp_list
77
- permutated_snp_error += Nimbus::LossFunctions.mean_squared_error [oobi], @id_to_fenotype, permutated_prediction
77
+ permutated_snp_error += Nimbus::LossFunctions.squared_difference @id_to_fenotype[oobi], permutated_prediction
78
78
  }
79
79
  @importances[current_snp] = ((permutated_snp_error / oob_individuals_count) - @generalization_error).round(5)
80
80
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nimbus
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.8"
5
+ version: "0.9"
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Juanjo Baz\xC3\xA1n"
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-08-23 00:00:00 Z
14
+ date: 2011-08-24 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec