private PredictionEngine <PageData, PageClassPrediction> LoadPredictionEngineFromCache() { if (!PredictionEngineCache.ContainsKey(ModelName)) { LoadPredictionEngineFromDiskIntoCache(ModelName); } return(PredictionEngineCache[ModelName]); }
private void LoadPredictionEngineFromDiskIntoCache(string modelName) { string path = GetModelFilePath(); if (!File.Exists(path)) { throw new FetchoException("{0} model doesn't exist", ModelName); } using (var stream = File.OpenRead(path)) PredictionEngineCache.Add(modelName, MLContext.Model.CreatePredictionEngine <PageData, PageClassPrediction>(MLContext.Model.Load(stream))); }