9
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ In 11.2, there are more man-kind information. $\endgroup$ Commented Sep 15, 2017 at 8:53
  • $\begingroup$ Thanks! What does "man-kind" mean though? :) $\endgroup$
    – iav
    Commented Sep 15, 2017 at 8:56
  • 1
    $\begingroup$ no number like 6662731484316300290, tree structure is more clear $\endgroup$ Commented Sep 15, 2017 at 8:57
  • $\begingroup$ @HyperGroups, would be grateful for any comment on how to recover the decision tree with 11.2 :) $\endgroup$
    – iav
    Commented Mar 20, 2018 at 13:01
  • 1
    $\begingroup$ "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"? $\endgroup$ Commented Mar 21, 2018 at 16:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.