Esempio n. 1
0
 public MachineLearningHealthCheck(
     IModelPredictionEngine <TInput, TPrediction> model,
     ILogger <MachineLearningHealthCheck <TInput, TPrediction> > logger)
 {
     _model  = model;
     _logger = logger;
 }
 public PredictionController(
     IModelPredictionEngine <SentimentObservation, SentimentPrediction> sentimentModel,
     IModelPredictionEngine <SpamInput, SpamPrediction> spamModel)
 {
     _sentimentModel = sentimentModel ?? throw new ArgumentNullException(nameof(sentimentModel));
     _spamModel      = spamModel ?? throw new ArgumentNullException(nameof(spamModel));
 }
Esempio n. 3
0
 public MachineLearningHealthCheck(
     IModelPredictionEngine <TInput, TPrediction> model,
     IOptionsMonitor <MachineLearningHealthCheckOptions <TInput> > optionsMonitor,
     ILogger <MachineLearningHealthCheck <TInput, TPrediction> > logger)
 {
     _model          = model ?? throw new ArgumentNullException(nameof(model));
     _optionsMonitor = optionsMonitor ?? throw new ArgumentNullException(nameof(optionsMonitor));
     _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
 }
        public static IEnumerable <TPrediction> Predict <TInput, TPrediction>(
            this IModelPredictionEngine <TInput, TPrediction> modelPredictionEngine,
            IEnumerable <TInput> dataSamples)
            where TInput : class
            where TPrediction : class, new()
        {
            var model = modelPredictionEngine.GetModel();

            return(modelPredictionEngine.GetBatch(model, dataSamples));
        }
        private static IEnumerable <TPrediction> GetBatch <TInput, TPrediction>(
            this IModelPredictionEngine <TInput, TPrediction> modelPredictionEngine,
            ITransformer model,
            IEnumerable <TInput> dataSamples)
            where TInput : class
            where TPrediction : class, new()
        {
            var data = modelPredictionEngine.MLContext.Data.LoadFromEnumerable(dataSamples);

            var dataView = model.Transform(data);

            return(modelPredictionEngine.MLContext.Data
                   .CreateEnumerable <TPrediction>(dataView, reuseRowObject: false).ToList());
        }
Esempio n. 6
0
        public static TPrediction Predict <TData, TPrediction>(
            this IModelPredictionEngine <TData, TPrediction> modelPredictionEngine,
            TData dataSample) where TData : class where TPrediction : class, new()
        {
            var modelPredictionEnginePool = modelPredictionEngine.GetPredictionEnginePool();
            var pool = modelPredictionEnginePool.Get();

            try
            {
                return(pool.Predict(dataSample));
            }
            finally
            {
                modelPredictionEnginePool.Return(pool);
            }
        }
        public static TPrediction Predict <TInput, TPrediction>(
            this IModelPredictionEngine <TInput, TPrediction> modelPredictionEngine,
            TInput dataSample)
            where TInput : class
            where TPrediction : class, new()
        {
            var engine = modelPredictionEngine.GetPredictionEngine();

            try
            {
                return(engine.Predict(dataSample));
            }
            finally
            {
                modelPredictionEngine.ReturnPredictionEngine(engine);
            }
        }
Esempio n. 8
0
 public SpamController(
     IModelPredictionEngine <SpamInput, SpamPrediction> spamModel)
 {
     _spamModel = spamModel ?? throw new ArgumentNullException(nameof(spamModel));
 }
 public SentimentController(
     IModelPredictionEngine <SentimentIssue, SentimentPrediction> sentimentModel)
 {
     _sentimentModel = sentimentModel ?? throw new ArgumentNullException(nameof(sentimentModel));
 }