summaryrefslogtreecommitdiff
path: root/lib/caret.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/caret.rb')
-rw-r--r--lib/caret.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/caret.rb b/lib/caret.rb
index df86093..2c4cd0c 100644
--- a/lib/caret.rb
+++ b/lib/caret.rb
@@ -9,6 +9,11 @@ module OpenTox
if independent_variables.flatten.uniq == ["NA"]
prediction = Algorithm::Regression::weighted_average dependent_variables:dependent_variables, weights:weights
prediction[:warning] = "No variables for regression model. Using weighted average of similar substances."
+ elsif
+ dependent_variables.size < 3
+ prediction = Algorithm::Regression::weighted_average dependent_variables:dependent_variables, weights:weights
+ prediction[:warning] = "Insufficient number of neighbors (#{dependent_variables.size}) for regression model. Using weighted average of similar substances."
+
else
dependent_variables.each_with_index do |v,i|
dependent_variables[i] = to_r(v)