From b3954d0969741bff4771f1d198b3126de19a8787 Mon Sep 17 00:00:00 2001 From: Anton Antonov Date: Tue, 17 Nov 2015 22:06:01 -0500 Subject: [PATCH] Added a check and a message for the first argument BuildDecisionTree to be a matrix of atoms. --- AVCDecisionTreeForest.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/AVCDecisionTreeForest.m b/AVCDecisionTreeForest.m index e89699a3..314672a9 100644 --- a/AVCDecisionTreeForest.m +++ b/AVCDecisionTreeForest.m @@ -411,6 +411,8 @@ Mathematica is (C) Copyright 1988-2012 Wolfram Research, Inc. BuildDecisionTree::lvalopt = "The value of `1` should be Automatic, All, or a subset of the class labels `2`."; +BuildDecisionTree::farg = "The first argument is expected to be a matrix all elements of which are atoms."; + Clear[BuildDecisionTree] Options[BuildDecisionTree] = {"RandomAxes" -> False, "ImpurityFunction" -> "Gini", "Strata" -> 100, @@ -511,8 +513,12 @@ Mathematica is (C) Copyright 1988-2012 Wolfram Research, Inc. BuildDecisionTree[data, {minSizeTh, 0.}, opts] /; NumberQ[minSizeTh]; BuildDecisionTree[data_, {minSizeTh_Integer, impurityTh_?NumberQ}, opts : OptionsPattern[]] := Block[{columnTypes}, + If[ !MatrixQ[ data, AtomQ], + Message[BuildDecisionTree::farg]; + Return[{}]; + ]; columnTypes = - Map[Apply[And, NumericQ /@ data[[All, #]]] &, Range[1, Length[data[[1]]]]]; + Map[ VectorQ[ data[[All, #]], NumericQ ] &, Range[1, Length[ data[[1]]] ] ]; columnTypes = columnTypes /. {True -> Number, False -> Symbol}; BuildDecisionTree[data, columnTypes, {Max[minSizeTh, 1], impurityTh}, opts] ];