From 3ce1bca67008c9abad81847c1203e1cc967c15e3 Mon Sep 17 00:00:00 2001 From: Rink Springer Date: Fri, 30 Jun 2017 15:32:40 +0200 Subject: [PATCH] Prevent crash when attempting to create training data without responses. This is at least useful when using an SVM one-class linear classifier, so there are valid use cases. --- modules/ml/src/data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ml/src/data.cpp b/modules/ml/src/data.cpp index e48030f347..07858a0333 100644 --- a/modules/ml/src/data.cpp +++ b/modules/ml/src/data.cpp @@ -403,7 +403,7 @@ public: Mat(tempCatMap).copyTo(catMap); } - if( varType.at(ninputvars) == VAR_CATEGORICAL ) + if( noutputvars > 0 && varType.at(ninputvars) == VAR_CATEGORICAL ) { preprocessCategorical(responses, &normCatResponses, labels, &counters, sortbuf); Mat(labels).copyTo(classLabels); -- GitLab