Class: Ossert::Classifiers::Growing
- Inherits:
-
Object
- Object
- Ossert::Classifiers::Growing
show all
- Defined in:
- lib/ossert/classifiers/growing.rb,
lib/ossert/classifiers/growing/check.rb,
lib/ossert/classifiers/growing/classifier.rb
Defined Under Namespace
Classes: Check, Classifier, ClassifiersInitializer
Constant Summary
collapse
- GRADES =
%w(
ClassA
ClassB
ClassC
ClassD
ClassE
).freeze
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Growing.
28
29
30
|
# File 'lib/ossert/classifiers/growing.rb', line 28
def initialize
(self.class.all ||= []) << self
end
|
Class Attribute Details
.all ⇒ Object
Returns the value of attribute all.
17
18
19
|
# File 'lib/ossert/classifiers/growing.rb', line 17
def all
@all
end
|
Instance Attribute Details
#agility_last_year_classifier ⇒ Object
Returns the value of attribute agility_last_year_classifier.
33
34
35
|
# File 'lib/ossert/classifiers/growing.rb', line 33
def agility_last_year_classifier
@agility_last_year_classifier
end
|
#agility_total_classifier ⇒ Object
Returns the value of attribute agility_total_classifier.
33
34
35
|
# File 'lib/ossert/classifiers/growing.rb', line 33
def agility_total_classifier
@agility_total_classifier
end
|
Returns the value of attribute community_last_year_classifier.
33
34
35
|
# File 'lib/ossert/classifiers/growing.rb', line 33
def
@community_last_year_classifier
end
|
Returns the value of attribute community_total_classifier.
33
34
35
|
# File 'lib/ossert/classifiers/growing.rb', line 33
def
@community_total_classifier
end
|
#train_group ⇒ Object
Returns the value of attribute train_group.
32
33
34
|
# File 'lib/ossert/classifiers/growing.rb', line 32
def train_group
@train_group
end
|
Class Method Details
.config ⇒ Object
23
24
25
|
# File 'lib/ossert/classifiers/growing.rb', line 23
def config
@config ||= Settings['classifiers']['growth']
end
|
.current ⇒ Object
19
20
21
|
# File 'lib/ossert/classifiers/growing.rb', line 19
def current
all.last
end
|
Instance Method Details
#check(*args) ⇒ Object
76
77
78
|
# File 'lib/ossert/classifiers/growing.rb', line 76
def check(*args)
process_using(*args.unshift(:check))
end
|
#classifier_to_metrics_per_grade(classifier) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/ossert/classifiers/growing.rb', line 51
def classifier_to_metrics_per_grade(classifier)
classifier.each_with_object({}) do |(grade, metrics), res|
metrics.each do |metric, value|
(res[metric] ||= {})[grade] = value
end
end
end
|
#grade(*args) ⇒ Object
72
73
74
|
# File 'lib/ossert/classifiers/growing.rb', line 72
def grade(*args)
process_using(*args.unshift(:grade))
end
|
#process_using(action, project, last_year_offset = 1) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/ossert/classifiers/growing.rb', line 59
def process_using(action, project, last_year_offset = 1)
Check.send(action,
self.class.config,
project,
{
agility_total: agility_total_classifier,
community_total: ,
agility_last_year: agility_last_year_classifier,
community_last_year:
},
last_year_offset)
end
|
#ready? ⇒ Boolean
36
37
38
|
# File 'lib/ossert/classifiers/growing.rb', line 36
def ready?
agility_total_classifier.keys == GRADES && .keys == GRADES
end
|
#reference_values_per_grade ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/ossert/classifiers/growing.rb', line 40
def reference_values_per_grade
{
agility_total: classifier_to_metrics_per_grade(agility_total_classifier),
agility_quarter: classifier_to_metrics_per_grade(agility_last_year_classifier),
agility_year: classifier_to_metrics_per_grade(agility_last_year_classifier),
community_total: classifier_to_metrics_per_grade(),
community_quarter: classifier_to_metrics_per_grade(),
community_year: classifier_to_metrics_per_grade()
}
end
|
#train ⇒ Object
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/ossert/classifiers/growing.rb', line 80
def train
classifiers_initializer = ClassifiersInitializer.load_or_create
classifiers_initializer.run
classifiers_initializer.classifiers.each do |name, classifier|
instance_variable_set(
"@#{name}_classifier",
Classifier.new(classifier, self.class.config).train
)
end
end
|