OK I have succeeded to make it work by using proper parts of the DataView code here :
https://zcusa.951200.xyz/fr-fr/dotnet/api/microsoft.ml.idataview?view=ml-dotnet
I can run the 16k predictions in few seconds.
I don't need the PredictionEnginePool as I am fine with the DatView solution.
Make lot of predictions from a file
Hello,
I have trained a model and I am able to get a single prediction.
I am trying to read a csv file to make lot of predictions. I am reading each line of this file and I get the content of the 2 columns, then from this I can make the prediction of each line in my input file.
To loop over all the lines and get for each line of the file the predition is very slow... I have tried to make 16k prediction and it took 8 hours.
I am not very familiar with ML.NET and I would like to make it faster.
Here is the code I am using :
string[] lines = System.IO.File.ReadAllLines(filename_in);
foreach (string line in lines)
{
string[] line_elements = line.Split(";");
// The necessary inputs
string elem1= line_elements[0];
string elem2= line_elements[1];
// Create single instance for model input
ML_categorie.ModelInput sampleData_categorie = new ML_categorie.ModelInput()
{
Elem1= elem1,
Elem2= elem2,
};
ML_categorie.ModelOutput result_categorie = ML_categorie.Predict(sampleData_categorie);
float predict_categorie = result_categorie.Prediction;
string categorie = predict_categorie.ToString();
}
-
DJamin 386 Reputation points
2021-10-01T08:01:41.283+00:00
1 additional answer
Sort by: Most helpful
-
DJamin 386 Reputation points
2021-09-30T07:43:38.75+00:00 I have tried to make multiple Predictions with IdataView from the official example :
https://zcusa.951200.xyz/fr-fr/dotnet/machine-learning/how-to-guides/machine-learning-model-predictions-ml-net
But it doesn't work ...
I don't know how to link :HousingData[] housingData = new HousingData[] IDataView predictions = predictionPipeline.Transform(inputData);
I am not clear how to declare inputData as a IDataView object ?
And the last example with PredictionEnginePool is completely impossible to understand.