5
$\begingroup$

Update: as @AntonAntoniv rightly noticed in his comment the case of DecisionTree is already discussed. Now it would be great to also have an equivalent answer for LogisticRegression.


MMA is really convenient to test/check various classiers, like DecisionTree, LogisticRegression, etc.. By example:

iris = ExampleData[{"MachineLearning", "FisherIris"}, "Data"];
data = GroupBy[iris, Last -> First];
c = Classify[data, Method -> "DecisionTree"];
cm = ClassifierMeasurements[c, data];
cm["ConfusionMatrixPlot"] 

enter image description here

Now suppose that I want to reuse the classifier elsewhere (for instance in a C++ code), is there any documentation about how to retrieve the relevant information like: tree structure, thresholds... etc?

I can do

c // InputForm

which prints a lot of information:

ClassifierFunction[<|"ExampleNumber" -> 150, "ClassNumber" -> 3,
"Input" -> <|"Preprocessor" -> MachineLearningMLProcessor["ToMLDataset", <|"Input" -> <|"f1" -> <|"Type" -> "NumericalVector", "Length" -> 4|>|>, "Output" -> <|"f1" -> <|"Type" -> "NumericalVector", "Weight" -> 1|>|>, "Preprocessor" -> MachineLearningMLProcessor["Sequence", <|"Processors" -> {MachineLearningMLProcessor["List"], MachineLearningMLProcessor["WrapMLDataset", <|"FeatureTypes" -> {"NumericalVector"}, "FeatureKeys" -> {"f1"}, "FeatureWeights" -> Automatic, "ExampleWeights" -> Automatic, "RawExample" -> Missing["KeyAbsent", "RawExample"]|>]}|>], "ScalarFeature" -> True, "Invertibility" -> "Perfect", "Missing" -> "Allowed"|>], "Processor" -> MachineLearningMLProcessor["Sequence", <|"Input" -> <|"f1" -> <|"Type" -> "NumericalVector", "Weight" -> 1|>|>, "Output" -> <|"f1" -> <|"Type" -> "NumericalVector", "Weight" -> 1|>|>, "Processors" -> {MachineLearningMLProcessor["ImputeMissing", <|"Invertibility" -> "Perfect", "Missing" -> "Imputed", "Input" -> <|"f1" -> <|"Type" -> "NumericalVector", "Weight" -> 1|>|>, "VectorLength" -> 4, "Imputer" -> (DimensionReducerFunction[<|"ExampleNumber" -> 150, "Imputer" -> MachineLearningMLProcessor["ImputeMissing", <|"Invertibility" -> "Perfect", "Missing" -> "Imputed", "Input" -> <|"f1" -> <|"Type" -> "NumericalVector", "Weight" -> 1|>|>, "VectorLength" -> 4, "Naive" -> True, "Fill" -> {5.843333333333335, 3.057333333333334, 3.7580000000000027, 1.199333333333334}, "Output" -> <|"f1" -> <|"Type" -> "NumericalVector", "Weight" -> 1|>|>, "Type" -> "NumericalVector"|>], "Preprocessor" -> MachineLearningMLProcessor["ToMLDataset",

....

... a long list ....

....

but AFAIK this structure is not documented.

In short is it possible the do "reverse engineering" of Classify function output? (I am espcially interested by DecitionTree and LogisticRegression).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.