Skip to content

Commit

Permalink
Added a check and a message for the first argument BuildDecisionTree …
Browse files Browse the repository at this point in the history
…to be a matrix of atoms.
  • Loading branch information
antononcube committed Nov 18, 2015
1 parent 39bdcdc commit b3954d0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion AVCDecisionTreeForest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
];
Expand Down

0 comments on commit b3954d0

Please sign in to comment.