Description
System information
- OS version/distro: Windows 10
- .NET Version (eg., dotnet --info): .NET 5.0
Issue
Assuming we create a new RegressionExperiment, generate some Test and Training Data and after Executing the Experiment we see that a FastTreeRegression was the BestRun of the ExperimentResult<RegressionMetrics>
.
In Scikit (Python), you can directly let the Library Plot the Descicion Tree, but in ML.NET I haven't found such a possibility yet.
Is there a simple way that I am missing to create some kind of data structure (or JSON) that would print the descicion tree? Favorably with Labels and the threshhold value.
I have found other issues concerning this Problem but they all were closed without an actual solution in 2018 or 2019, so this didn't help me at all, sadly.
I know we can extract the Transformer and corresponding TreeEnsemble from a RunDetail<RegressionMetrics>
via some ugly casting (((PredictionTransformerBase<Microsoft.ML.Trainers.FastTree.FastTreeRegressionModelParameters>)((TransformerChain<IPredictionTransformer<object>>)bestRun.Model)
), but I sadly do not know where to go from there.
And since I am not too familiar with the API as well - Is there any built-in way on receiving the Information on how the descicion tree(s) is/are built up which can also be used to visualize as a graph?
Source code / logs
What I am doing at the moment looks something like this:
RegressionExperiment experiment = context.Auto().CreateRegressionExperiment(60 * 10);
var trainTestData = CreateTrainTestData(); //Create some testdata with TrainTestSplit
ExperimentResult<RegressionMetrics> experimentResult = experiment.Execute(trainTestData.TrainSet, "Label")
//We assume we will always get a FastDescicionTree for the example
var transformer = ((PredictionTransformerBase<Microsoft.ML.Trainers.FastTree.FastTreeRegressionModelParameters>)((TransformerChain<IPredictionTransformer<object>>)bestRun.Model).LastTransformer;
var ensemble = transformer.Model.TrainedTreeEnsemble;
//Now, how to visualize?