I'm trying to follow the example for PFI. The last transform of my pipeline is a ColumnCopyingTransformer
, so pipeline.Fit(trainingDataView).LastTransformer
is that type. However, MLContext.MulticlassClassification.PermutationFeatureImportance
expects IPredictionTransformer<IPredictor>
. It feels like the example was crafted with a very specific pipeline in mind.
I got this tip via the ML.Net gitter channel:
You can iterate over your transformer chain pipeline.Fit(trainingDataView) until you find something which is IPredictionTransformer
However, I don't see how to perform that iteration. I tried the following but get null for predictor.
var trainedModel = (TransformerChain<ITransformer>)mlContext.Model.Load(stream);
var predictor = trainedModel.OfType<IPredictionTransformer<IPredictor>>().FirstOrDefault();
What am I missing?