Diversity prediction theorem: Difference between revisions
→{{header|Ruby}}: remove square method
(→{{header|Ruby}}: Add truth and predictions to output) |
(→{{header|Ruby}}: remove square method) |
||
Line 1,422:
=={{header|Ruby}}==
{{trans|D}}
<lang ruby>def
def mean_square_diff(a, predictions) = mean(predictions.map { |x| square(x - a)**2 })▼
▲def mean_square_diff(a, predictions) = mean(predictions.map { |x| square(x - a) })
def diversity_theorem(truth, predictions)
Line 1,430 ⟶ 1,429:
puts "truth: #{truth}, predictions #{predictions}",
"average-error: #{mean_square_diff(truth, predictions)}",
"crowd-error: #{
"diversity: #{mean_square_diff(average, predictions)}",""
end
|