Class: Eps::LinearRegression
Class Method Summary
collapse
Instance Method Summary
collapse
#evaluate, extract_text_features, #initialize, #predict, #summary, #to_pmml
Class Method Details
.load_pmml(data) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/eps/linear_regression.rb', line 5
def self.load_pmml(data)
super do |data|
node = data.css("RegressionTable")
coefficients = {
"_intercept" => node.attribute("intercept").value.to_f
}
features = {}
text_features, derived_fields = (data, features)
node.css("NumericPredictor").each do |n|
name = n.attribute("name").value
if derived_fields[name]
name = derived_fields[name]
else
features[name] = "numeric"
end
coefficients[name] = n.attribute("coefficient").value.to_f
end
node.css("CategoricalPredictor").each do |n|
name = n.attribute("name").value
coefficients[[name, n.attribute("value").value]] = n.attribute("coefficient").value.to_f
features[name] = "categorical"
end
Evaluators::LinearRegression.new(coefficients: coefficients, features: features, text_features: text_features)
end
end
|
Instance Method Details
#adjusted_r2 ⇒ Object
46
47
48
|
# File 'lib/eps/linear_regression.rb', line 46
def adjusted_r2
@adjusted_r2 ||= (mst - mse) / mst
end
|
#coefficients ⇒ Object
38
39
40
|
# File 'lib/eps/linear_regression.rb', line 38
def coefficients
@evaluator.coefficients
end
|
#r2 ⇒ Object
42
43
44
|
# File 'lib/eps/linear_regression.rb', line 42
def r2
@r2 ||= (sst - sse) / sst
end
|