public void CreateEnergyUsage() { BinaryData binaryData = new BinaryData() { Value = "urn:sif:school:AcmeMiddleSchool1.CoyoteDistrict.Arizona" }; UsageLocationInfo usageLocationInfo = new UsageLocationInfo() { SchoolId = binaryData }; ReadingData readingData = new ReadingData() { EnergyUnits = "$Kilowatt-Hour" }; ReadingDataList readingDataList = new ReadingDataList() { readingData }; DataSource dataSource = new DataSource() { ReadingDataList = readingDataList }; EnergyUsage energyUsage = new EnergyUsage() { UsageLocationInfo = usageLocationInfo, DataSource = dataSource }; if (log.IsDebugEnabled) { log.Debug("EnergyUsage instance: " + energyUsage.ToXml()); } Console.WriteLine("EnergyUsage instance: " + energyUsage.ToXml()); }
public PredictionResult Predict() { var _MLContext = new MLContext(); var PredictionResultList = new List <Predictions>(); var predictionFunction = _MLContext.Model.CreatePredictionEngine <EnergyUsage, EnergyUsagePrediction>(_trainedModel); var results = new PredictionResult { Center = _center.CenterAbbr, ModelUsed = _center.BestTrainer }; foreach (var fc in _forecast.Periods) { var test = new EnergyUsage() { Center = _center.CenterAbbr, DayOfWeek = (int)fc.startTime.DayOfWeek, Hour = fc.startTime.Hour, AvgTemp = fc.temperature, kWH = 0 }; var prediction = predictionFunction.Predict(test); var pr = new Predictions() { kWH_Usage = prediction.kWH, Hour = test.Hour }; results.Predictions.Add(pr); } return(results); }
// GET: EnergyUsage public ActionResult Index(string location, string type, string timePeriod) { EnergyUsage result = new EnergyUsage(); // gets individal energy usage in kwh and rounding it off to 2dp ViewBag.sum = Math.Round(result.IndividualEnergyUsage(location, type, timePeriod), 2); ViewBag.location = location; return(View(result)); }
// GET: EnergyUsage public ActionResult Index(string location, string type, string timePeriod) { _session = Session.getInstance; if (_session != null) { EnergyUsage result = new EnergyUsage(); // gets individal energy usage in kwh and rounding it off to 2dp ViewBag.sum = Math.Round(result.IndividualEnergyUsage(location, type, timePeriod), 2); ViewBag.location = location; return(View(result)); } else { return(RedirectToAction("Index", "Home")); } }
// GET: EnergyUsage public ActionResult Index(string location, string name, string timePeriod) { _session = Session.getInstance; if (_session != null) { EnergyUsage result = new EnergyUsage(timePeriod); if (location == null) { result.Location = result.Locations[0]; } else { result.Location = location; } if (name == null) { result.Name = result.DevicesInLocation[0]; } else { result.Name = name; } if (timePeriod == null) { result.TimePeriod = "daily"; } else { result.TimePeriod = timePeriod; } return(View(result)); } else { return(RedirectToAction("Index", "Home")); } }
public IEnumerable <EnergyUsage> GetTrainingData(Center center, string startDate, string endDate) { var a = DateTime.Parse(startDate); var z = DateTime.Parse(endDate); var tempData = (ctx.IconicsData.Where(x => x.CenterAbbr == center.CenterAbbr && x.TimeStamp >= a && x.TimeStamp <= z && x.Fulltag.Contains("Temperature_F")).ToList()); var energyData = (ctx.IconicsData.Where(x => x.CenterAbbr == center.CenterAbbr && x.TimeStamp >= a && x.TimeStamp <= z && x.Fulltag.Contains("Peak_DEM")).ToList()); var merged = (from temp in tempData join energy in energyData on temp.TimeStamp equals energy.TimeStamp select new { Center = temp.CenterAbbr, AvgTemp = temp.AvgValue, kWH = energy.AvgValue, Date = temp.TimeStamp, }).ToList(); var usage = new List <EnergyUsage>(); foreach (var m in merged) { var e = new EnergyUsage() { Center = m.Center, AvgTemp = Math.Round(m.AvgTemp, 6, MidpointRounding.ToEven), kWH = float.Parse(Math.Round(m.kWH, 6, MidpointRounding.ToEven).ToString()), DayOfWeek = (int)m.Date.DayOfWeek, Hour = m.Date.Hour }; usage.Add(e); } return(usage.AsEnumerable()); }
public Predictions PredictSingle() { var _MLContext = new MLContext(); var PredictionResultList = new List <Predictions>(); var predictionFunction = _MLContext.Model.CreatePredictionEngine <EnergyUsage, EnergyUsagePrediction>(_trainedModel); var test = new EnergyUsage() { Center = _center.CenterAbbr, DayOfWeek = (int)_testObj.DayOfWeek, Hour = _testObj.Hour, AvgTemp = _testObj.Temperature, kWH = 0 // To }; var prediction = predictionFunction.Predict(test); var predictionResult = new Predictions() { kWH_Usage = prediction.kWH, Hour = test.Hour }; return(predictionResult); }
private void FetchData() { _energyUsageByActivityType = _statisticsDataService.GetActualStatisticsByActivityTypeData().Result; _energyUsageByCity = _statisticsDataService.GetActualStatisticsByCityData().Result; _responseTime = DateTime.Now; }