9

I want to extract the parameters of a decision tree from the object estimated by Classify[].

It seems that parameters of the estimated Classifier are available in the "Models" property. It is straightforward to extract them for the LogisticRegression:

trainingset = {{1, 1} -> "A", {2, 2} -> "A", {3.5, 3.5} -> "B", {4, 4} -> "B"};
c = Classify[trainingset, Method -> "LogisticRegression"]
c[[1]]@"Models"
(*<|"Theta" -> {3.313488895251318`, -22.972972516102526`}, "L1Regularization" -> 0, "L2Regularization" -> 1.`*^-10, "FeatureNumber" -> 1, "Method" -> "LogisticRegression", ...|>*)

"Theta" contains needed data. However, it is not obvious how to read the output for RandomForest:

 c = Classify[trainingset, Method -> {"RandomForest", "TreeNumber" -> 1}]
 (c[[1]]@"Models")[[1]]
 (*<|"Method" -> "RandomForest", "Trees" -> {{{1}, {-6662731484316300290}, {-1}, {-2}}}, "FeatureNumber" -> 1, "TreeNumber" -> 1, "LeafSize" -> 1, ...| >*)

How do I convert this ""Trees" -> {{{1}, {-6662731484316300290}, {-1}, {-2}}}" into "if then" structure? What do these numbers mean?

updated Mar-18 version 11.2

Now to extract the parameters instead "Models" we need to call for "Model", which yields:

(c[[1]]@"Model")[[1]]

{<|FeatureIndices->RawArray[Integer16,<1>],NominalSplits->{},NumericalThresholds->RawArray[Real32,<1>],Children->RawArray[Integer16,<1,2>],LeafValues->RawArray[UnsignedInteger8,<2>],RootIndex->1,NominalDimension->0|>}

Supposedly, we need to look at:

((c[[1]]@"Model")[[1]])[[1]]@"NumericalThresholds" // Normal

{0.104828}

Still, not clear what does this number mean. How can I recover a decision tree from this output?

iav
  • 2,006
  • 17
  • 26

0 Answers0