public override float Predict(ModelDataSet input) { if (TrainedModel == null) { throw new Exception("Must initialize the model before calling"); } lock (TrainedModel) { // cache for reuse if (PredictInput == null) { PredictInput = new float[input.Features()]; } for (int i = 0; i < PredictInput.Length; i++) { PredictInput[i] = input.Feature(i); } using (var arr = InputArray.Create <float>(PredictInput)) { return(TrainedModel.Predict(arr)); } } }
public override float Predict(float[] data) { if (TrainedModel == null) { throw new InvalidOperationException("Must train/load a model before predicting"); } lock (TrainedModel) { using (var arr = InputArray.Create <float>(data)) { return(TrainedModel.Predict(arr)); } } }
public override float Predict(DataSet data) { if (TrainedModel == null) { throw new InvalidOperationException("Must train/load a model before evaluating"); } lock (TrainedModel) { #if ML_LEGACY var result = TrainedModel.Predict(data); return(result.Score); #else var result = PredictFunc.Predict(data); return(result.Score); #endif } }
public override float Predict(ModelDataSet data) { if (TrainedModel == null) { throw new Exception("Must initialize the model before calling"); } lock (TrainedModel) { #if ML_LEGACY var result = TrainedModel.Predict(data); return(result.Score); #else var result = PredictFunc.Predict(data); return(result.Score); #endif } }