Skip to content

AutoML 2.0: How to get trainer used for best model #6651

Open

Description

@torronen

I am using latest version from [main] per today. At end of the trial, I want to log parameters and trainer used. I also want to get global feature index. My code* for global feature index relies on knowing which trainer is used.

For now, I intend to "hack" it this way. I believe this will be adequate for my need (not yet tested):
var pipelineString = pipeline.ToString(experimentResults.TrialSettings.Parameter);
if(pipelineString.Contains("FastTree")

However, it would be good to have documentation or implementation, if needed, to read the parameters in a structured format. I have not looked at the source, so maybe it just needs a sample or documentation.

*my code for GFI uses this code, and I have different lines for each tree trainer. If there are better ways it would make my life easier...

Microsoft.ML.Data.TransformerChain<Microsoft.ML.IPredictionTransformer<object>> transformerchain = (model as Microsoft.ML.Data.TransformerChain<Microsoft.ML.IPredictionTransformer<object>>);
                    Microsoft.ML.Data.BinaryPredictionTransformer<**Microsoft.ML.Calibrators.CalibratedModelParametersBase<Microsoft.ML.Trainers.FastTree.FastTreeBinaryModelParameters, Microsoft.ML.Calibrators.PlattCalibrator>**>
lastTransformer = (BinaryPredictionTransformer<CalibratedModelParametersBase<FastTreeBinaryModelParameters, PlattCalibrator>>)transformerchain.LastTransformer;

lastTransformer.Model.SubModel.GetFeatureWeights(ref weights);
float[] weightsValues = weights.DenseValues().ToArray();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-AutoMLAutomated machine learning, Model Builder, and ML.NET CLIenhancementNew feature or requestneeds-further-triageNeeds deeper review after initial triageuntriagedNew issue has not been triagedyellowmaintenance only

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions