Predict hangs indefinetly
System information
- OS version/distro: Mac OS X 10.13
- .NET Version (eg., dotnet --info): 2.0.5
Issue
- I have a
.csvfile with data that I use for individual predictions. I use aFastTreeRegressormodel loaded from disk. I make individual predictions and not batch predictions because I need the absolute error histogram. At first, predicting works fine, but then, after what appears to be a random number of executions, thePredictmethod hangs without anything else happening. - I expect either
Predictfailing with some Exception, or better, fail for the same example or, even better,Predictto work for all my examples, which it should.
By random I mean that I have a few million examples I have to go through, but predicting stops anywhere between after a few hundreds predictions or at best after a few thousands.
Source code / logs
The stripped down source code for Program.cs. Note that I have also tried with version 0.2
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.ML;
using PredictionModelling;
namespace PredictionMetrics
{
class Program
{
static async Task Main(string[] args)
{
foreach (string culture in cultures)
{
var model = await PredictionModel.ReadAsync<Data, DataPrediction>("model.zip");
StreamReader file = new StreamReader("test.csv");
file.ReadLine(); // This is for the header
string line;
using (StreamWriter outputFile = new StreamWriter("test-predictions.csv"))
{
var i = 0;
outputFile.WriteLine($"actual-value,predicted-value");
while ((line = file.ReadLine()) != null)
{
var data = line.Split(new[] { ',' });
var data = new Data()
{
Feature0 = float.Parse(data[0]),
Feature1 = float.Parse(data[1])
};
var csvLine = $"{data[2]},{model.Predict(data).Value}";
outputFile.WriteLine(csvLine);
i++;
if (i % 100 == 0)
{
outputFile.Flush();
}
}
}
file.Close();
}
}
}
}
Cosmin, Do you happen to have any filters in your trained pipeline? Sometimes, if you filter the input row during training, the prediction engine would also filter rows to score and that can stall the pipeline. Ideally, the trained model does not have any filter transforms and all filtering is done before training. For example, if you have missing values it is good idea to replace the NAFilter with NAHandle transform.
I do not have any filters. The model pipeline looks like this:
var pipeline = new LearningPipeline();
pipeline.Add(new TextLoader<SearchesData>(DataPath, useHeader: true, separator: ","));
pipeline.Add(new ColumnCopier(("Value", "Label")));
pipeline.Add(new ColumnConcatenator("Features", "Feature1", "Feature2"));
pipeline.Add(new FastTreeRegressor() { DiskTranspose = true });
The API has changed since this bug was filed, @shmoradims can you verify if this is still valid.
@cosmincatalin , could you please provide your csv data file for repro? thanks.
@shmoradims , unfortunately I have moved on and I do not have the test data any moe. But I can tell you there were around 20 million samples with 18 numerical features. I'm sure that no matter what numbers you put in there it's going to be similar to my experiment.
Now, the pattern outlined above is bad, because instead of predicting in batches, I was predicting one by one. This is obviously less than ideal, but it shouldn't break, and if it breaks there should be an exception. I now use batches, so the issue is of no interest to me anymore, but I though I'd leave it open anyway so that a potential problem can be found.
Thanks @cosmincatalin.
@yaeldekel we should have some click dataset similar to above for repro.
This issue seems to have happened with the old API. We have the new API now that you should use and provide a repro, until then I will close this issue.