Class: RSpec::FlakeClassifier::Predictor::Trainer
- Inherits:
-
Object
- Object
- RSpec::FlakeClassifier::Predictor::Trainer
- Defined in:
- lib/rspec/flake/classifier/predictor.rb
Instance Method Summary collapse
-
#initialize(examples) ⇒ Trainer
constructor
A new instance of Trainer.
- #weights ⇒ Object
Constructor Details
#initialize(examples) ⇒ Trainer
Returns a new instance of Trainer.
90 91 92 |
# File 'lib/rspec/flake/classifier/predictor.rb', line 90 def initialize(examples) @examples = examples end |
Instance Method Details
#weights ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/rspec/flake/classifier/predictor.rb', line 94 def weights positives = examples.select { |example| flaky?(example) } negatives = examples.reject { |example| flaky?(example) } return WEIGHTS if positives.empty? || negatives.empty? raw = WEIGHTS.keys.to_h do |key| [key, [average(positives, key) - average(negatives, key), 0.0].max] end normalize(raw) end |