# How to extract tree parameters from RandomForest?

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[]@"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[]@"Models")[]
(*<|"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[]@"Model")[]


{<|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[]@"Model")[])[]@"NumericalThresholds" // Normal


{0.104828}

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

• In 11.2, there are more man-kind information. – HyperGroups Sep 15 '17 at 8:53
• Thanks! What does "man-kind" mean though? :) – iav Sep 15 '17 at 8:56
• no number like 6662731484316300290`, tree structure is more clear – HyperGroups Sep 15 '17 at 8:57
• @HyperGroups, would be grateful for any comment on how to recover the decision tree with 11.2 :) – iav Mar 20 '18 at 13:01
• "I want to extract the parameters of a decision tree from the object estimated by Classify[]." -- Doesn't this meant that you should look in the method "DecisionTree" not "RandomForest"? – Anton Antonov Mar 21 '18 at 16:03