Skip to content

Commit 3ce1bca

Browse files
zhmurs-ph-lps
authored andcommitted
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.
1 parent a84a5e8 commit 3ce1bca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/ml/src/data.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ class TrainDataImpl : public TrainData
403403
Mat(tempCatMap).copyTo(catMap);
404404
}
405405

406-
if( varType.at<uchar>(ninputvars) == VAR_CATEGORICAL )
406+
if( noutputvars > 0 && varType.at<uchar>(ninputvars) == VAR_CATEGORICAL )
407407
{
408408
preprocessCategorical(responses, &normCatResponses, labels, &counters, sortbuf);
409409
Mat(labels).copyTo(classLabels);

0 commit comments

Comments
 (0)