public async Task <PredictionModel <UsageOfLightBulbModel, UsageOfLightBulbPredictionModel> > Train()
        {
            var dataFromDb = await _lightBulbRepository.GetAllLightBulbs();

            var dataToTrain = new List <UsageOfLightBulbModel>(dataFromDb);

            var collection = CollectionDataSource.Create(dataToTrain);

            var pipeline = new LearningPipeline
            {
                collection,
                new ColumnCopier(("IsOn", "Label")),
                new ColumnConcatenator(
                    "Features",
                    "LightBulbID",
                    "Month",
                    "Day",
                    "Time"),
                new FastTreeRegressor(),
            };

            model = pipeline.Train <UsageOfLightBulbModel, UsageOfLightBulbPredictionModel>();

            //  await model.WriteAsync(_modelpath);
            return(model);
        }
Exemple #2
0
 public async Task <IActionResult> Get()
 {
     return(new ObjectResult(await _lightBulbRepository.GetAllLightBulbs()));
 }