adaboost 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/adaboost/adaboost.rb +15 -14
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0f5373579f8f93316192361c02c0b29e176f09b
4
- data.tar.gz: 6f1c7a127b3b2283fab1b2bf3b4679e32e4587b7
3
+ metadata.gz: f550adc8429f2927416f49e86461497d9f43a072
4
+ data.tar.gz: bf2fa99dad4d438a25588f93d8de7a2c62c7f45f
5
5
  SHA512:
6
- metadata.gz: 28f2c7b14a2e372be409a593c0ec45fda9feedbb08d700ae85b2714dbea3121aba8660b271711a4dac67245293fed1c579cebc662040dfc6d89e6db7d85f9c84
7
- data.tar.gz: 6ea5ebf0d20243bbb5ba409990d3f7950d842a6a713ee6f14169ab96832e95d7b0296c884c63322f9c5066fc3511387fc775350fc1e63102625af2aa848734ed
6
+ metadata.gz: 38b3488dd4d034e9694200841a8b1c5022b60f8e8cb06afd88b99147dc140b73183153b12d7ba5c79e06865969958051dee9b59ef76af91e2901731626681b6b
7
+ data.tar.gz: 8f41f660c6a53b66ee8eed9a80b3948a66bae0bb516ab8d4f52d3322a66c0f40f9201f700cb499be885c5727bc1d2b65966efd04f48fe4bfdcb4453c8607fed9
@@ -23,6 +23,7 @@ module AdaBoost
23
23
  weak_classifier.compute_alpha
24
24
  update_weights weak_classifier, samples
25
25
  @weak_classifiers << weak_classifier
26
+ yield i, weak_classifier if block_given?
26
27
  end
27
28
  end
28
29
 
@@ -50,21 +51,21 @@ module AdaBoost
50
51
  negative_weight = 1 / samples_size
51
52
  positive_weight = negative_weight
52
53
  if Config::INCORPORATE_COST_SENSITIVE_LEARNING
53
- analyzer = FeaturesAnalyzer.new @y_index
54
- distribution = analyzer.analyze(samples).distribution
55
- positive_rate = distribution.positive / samples_size
56
- negative_rate = distribution.negative / samples_size
57
- normalizing_constant = distribution.negative * positive_rate + distribution.positive * negative_rate
58
- positive_weight = positive_rate / normalizing_constant.to_f
59
- negative_weight = negative_rate / normalizing_constant.to_f
54
+ analyzer = FeaturesAnalyzer.new @y_index
55
+ distribution = analyzer.analyze(samples).distribution
56
+ positive_rate = distribution.positive / samples_size
57
+ negative_rate = distribution.negative / samples_size
58
+ normalizing_constant = distribution.negative * positive_rate + distribution.positive * negative_rate
59
+ positive_weight = positive_rate / normalizing_constant.to_f
60
+ negative_weight = negative_rate / normalizing_constant.to_f
60
61
  end
61
62
  samples.each_with_index do |sample, i|
62
- y = sample[@y_index]
63
- if y == -1
64
- @weights[i] = positive_weight
65
- else
66
- @weights[i] = negative_weight
67
- end
63
+ y = sample[@y_index]
64
+ if y == -1
65
+ @weights[i] = positive_weight
66
+ else
67
+ @weights[i] = negative_weight
68
+ end
68
69
  end
69
70
  end
70
71
 
@@ -76,7 +77,7 @@ module AdaBoost
76
77
  sum += @weights[i]
77
78
  end
78
79
  @weights.each_with_index do |_, i|
79
- @weights[i] /= sum
80
+ @weights[i] /= sum
80
81
  end
81
82
  end
82
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adaboost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dalmir da Silva