1

I did exactly as this documentation says

https://learn.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/machine-learning-model-predictions-ml-net

I have this code to predict multiple input data (ML.Net 1.7)

var predEngine = mlContext.Model.CreatePredictionEngine<ClusterData,
                                        SentimentPrediction>(model);
var batchData = mlContext.Data.LoadFromEnumerable(listBatch);
IDataView predictions = model.Transform(batchData);

// Get Predictions
float[] scoreColumn = predictions.GetColumn<float>("Score").ToArray();

And I get this error in the last line:

 error CS1061: 'IDataView' does not contain a definition for 'GetColumn' and 
 no accessible extension method 'GetColumn' accepting a first argument of type 'IDataView'
 could be found (are you missing a using directive or an assembly reference?)
1
  • The documentation of IDataView does not contain any method GetColumn, therefore the compiler error is right. But its property Schema is of type Microsoft.ML.DataViewSchema contains a method GetColumnOrNull Commented Jan 20, 2022 at 14:35

1 Answer 1

1

It means that the code is trying to call the GetColumn method on an instance of the IDataView type, but the method doesn't exist.

To resolve the issue, you should:

  1. Make sure you have the necessary using directive or assembly reference.
  2. Check if the correct version of the Microsoft.ML.Data library is referenced in your project.
  3. Make sure the column you're trying to access actually exists in the data view.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.