Skip to content

InvalidCastException #16779

@paulh-rnd

Description

@paulh-rnd

I'm getting an InvalidCastException on the following line, when using the code unmodified from this documentation:

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

The full exception message is:

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

I'm using Microsoft.ML v1.4.0 in a .Net Core 2.1 console app.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions