Exemple #1
0
        public async Task <IActionResult> Execute([Bind("Name,ReferencePoint,F1_Score,Run_Date,RunOutput,Control_Y")] ModelRun model)
        {
            model.Control_Y = new List <int>();
            model.RunOutput = new List <int>();
            dataModel       = _context.Models.First(x => x.Name == model.Name);
            List <DataPoint> dataPoints = _context.DataPoints.ToList();

            foreach (DataPoint point in dataPoints)
            {
                decimal value = point.X1 * dataModel.Percentage1;
                value += point.X2 * dataModel.Percentage2;
                value += point.X3 * dataModel.Percentage3;
                value += point.X4 * dataModel.Percentage4;
                value += point.X5 * dataModel.Percentage5;
                value += point.X6 * dataModel.Percentage6;
                model.Control_Y.Add(point.Y);
                if (value >= model.ReferencePoint)
                {
                    model.RunOutput.Add(1);
                }
                else
                {
                    model.RunOutput.Add(0);
                }
            }
            for (int i = 0; i < model.RunOutput.Count; i++)
            {
                string entry = model.Control_Y[i].ToString() + "," + model.RunOutput[i].ToString();
                if (keyValuePairs.ContainsKey(entry))
                {
                    keyValuePairs[entry] += 1;
                }
            }

            model.F1_Score = Math.Round(CalculateF1Score(), 2);

            if (ModelState.IsValid)
            {
                _context.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "ModelRun"));
            }

            return(View(model));
        }
Exemple #2
0
        public IActionResult Execute(int id)
        {
            dataModel = _context.Models.First(x => x.ID == id);
            ModelRun model = new ModelRun
            {
                F1_Score = 0,
                Run_Date = DateTime.Now
            };

            model.Name = dataModel.Name;
            if (dataModel == null)
            {
                return(NotFound());
            }

            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> ExecuteAll([Bind("ReferencePoint")] ModelRun modelRun)
        {
            List <int>       target     = new List <int>();
            List <DataModel> dataModels = _context.Models.ToList();
            List <DataPoint> dataPoints = _context.DataPoints.ToList();

            foreach (DataPoint point in dataPoints)
            {
                target.Add(point.Y);
            }

            foreach (DataModel model in dataModels)
            {
                ModelRun prime = new ModelRun
                {
                    ReferencePoint = modelRun.ReferencePoint,
                    Control_Y      = target,
                    RunOutput      = new List <int>(),
                    Name           = model.Name,
                    Run_Date       = DateTime.Now,
                };

                foreach (DataPoint point in dataPoints)
                {
                    decimal value = point.X1 * model.Percentage1;
                    value += point.X2 * model.Percentage2;
                    value += point.X3 * model.Percentage3;
                    value += point.X4 * model.Percentage4;
                    value += point.X5 * model.Percentage5;
                    value += point.X6 * model.Percentage6;

                    if (value >= prime.ReferencePoint)
                    {
                        prime.RunOutput.Add(1);
                    }
                    else
                    {
                        prime.RunOutput.Add(0);
                    }

                    int    last  = prime.RunOutput.Count - 1;
                    string entry = prime.Control_Y[last].ToString() + "," + prime.RunOutput[last].ToString();
                    if (keyValuePairs.ContainsKey(entry))
                    {
                        keyValuePairs[entry] += 1;
                    }
                }

                prime.F1_Score = Math.Round(CalculateF1Score(), 2);
                if (ModelState.IsValid)
                {
                    _context.Add(prime);
                    await _context.SaveChangesAsync();
                }

                //reset counters
                resetDictionaryCount();
            }

            return(RedirectToAction("Index", "ModelRun"));
        }