Issues when retraining a model

DJamin 386 Reputation points
2021-10-08T12:42:01.677+00:00

Dear experts,

I am following the retraining page and I have issues :
https://learn.microsoft.com/fr-fr/dotnet/machine-learning/how-to-guides/retrain-model-ml-net

1/ I am not clear about where I can find the data_prep_pipeline.zip file ?

    // Load data preparation pipeline  
    ITransformer dataPrepPipeline = mlContext.Model.Load("data_preparation_pipeline.zip", out dataPrepPipelineSchema);  
      
    // Load trained model  
    ITransformer trainedModel = mlContext.Model.Load("ogd_model.zip", out modelSchema);  

I have performed training by doing Add/Machine Learning and following the clickable steps.
Then after testing step, I have saved the project and I can only find the model.zip file in the output directory.
-> So I have assumed that everything goes into the model.zip file. And I have used the "ITransformer trainedModel" as "ITransformer dataPrepPipeline".

2/ The line :

        LinearRegressionModelParameters originalModelParameters =  
            ((ISingleFeaturePredictionTransformer<object>)trainedModel).Model as LinearRegressionModelParameters;  

returns the following error :

System.InvalidCastException : 'Unable to cast object of type 'Microsoft.ML.Data.TransformerChain`1[Microsoft.ML.ITransformer]' to type 'Microsoft.ML.ISingleFeaturePredictionTransformer`1  

How can I solve this?
I hope that someone can help me.

Best regards,
David Jamin

.NET Machine learning
.NET Machine learning
.NET: Microsoft Technologies based on the .NET software framework.Machine learning: A type of artificial intelligence focused on enabling computers to use observed data to evolve new behaviors that have not been explicitly programmed.
150 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Ding,Xiaoxia 0 Reputation points
    2023-12-02T14:16:07.3233333+00:00

    I have the same problem!

    0 comments No comments