public MainWindow() { InitializeComponent(); Drawer pen = new Drawer(predictionChart); Drawer pen2 = new Drawer(predictionChart2); Drawer pen3 = new Drawer(predictionChart3); List <double> vs = new List <double>(); for (int i = 0; i < 30; i++) { vs.Add(Math.Sin(i)); } pen.DrawLinerChart(vs.ToArray(), "Pred"); var pred = PredictionUpdate.Prediction(vs, 20, true); pen.DrawLinerChart(pred.ToArray(), "Pred"); MainData mainData = new MainData(); mainData.Load_TXT("Сетевые-атаки(кол-во).txt"); var pred2 = PredictionUpdate.Prediction(mainData.GetData().ToList(), 0, true); pen3.DrawLinerChart(pred2.ToArray(), "pred"); pen3.DrawLinerChart(mainData.GetData(), "main"); MainData mainData2 = new MainData(); mainData2.Load_TXT("Сетевые-атаки.txt"); var pred3 = PredictionUpdate.Prediction(mainData2.GetData().ToList(), 0, true); pen2.DrawLinerChart(pred3.ToArray(), "pred"); pen2.DrawLinerChart(mainData2.GetData(), "main"); }
public static void GetAnaliticsPoly(CartesianChart cc, DataGrid dgv, double[] data, int x, int y, bool darbin, string dn, string dv, string countG) { _x = x; analitics = new PredictionM(); Drawer pen = new Drawer(cc); var buffer_data = data.Skip(x).Take(y - x + 1); int count = 0; double[] buffer = new double[y - x + 1]; foreach (var item in buffer_data) { buffer[count] = Convert.ToDouble(item); count++; } double[] arr_analitics = PredictionUpdate.Prediction(buffer.ToList(), 0, darbin, Convert.ToDouble(dn.Replace(".", ",")), Convert.ToDouble(dv.Replace(".", ",")), countG).ToArray(); pen.DrawLinerChart(arr_analitics, x, "Аналитика"); //List<Darbin> table = new List<Darbin>(); //for (int i = 0; i < analitics.darbi.Length; i++) //{ // table.Add(new Darbin { N = (i + 1).ToString(), D = analitics.darbi[i] }); //} double error = 0; double sum = 0; for (int i = 0; i < buffer.Length; i++) { sum += (Math.Abs(buffer[i] - arr_analitics[i]) / buffer[i]) * 100; } error = sum / buffer.Length; //table.Add(new Darbin { N = "Средняя ошибка", D = Math.Round(error, 2) }); //dgv.ItemsSource = table; Darbins = PredictionUpdate.darbins; }
public static void GetPredictionPoly(CartesianChart cc, double[] data, int x, int y, int number, bool darbin, string dn, string dv) { if (analitics == null) { MessageBox.Show("Вы не проанализировали временной ряд."); return; } Drawer pen = new Drawer(cc); var buffer_data = data.Skip(x).Take(y - x + 1); int count = 0; double[] buffer = new double[y - x + 1]; foreach (var item in buffer_data) { buffer[count] = Convert.ToDouble(item); count++; } double[] arr_analitics = PredictionUpdate.Prediction(buffer.ToList(), number, darbin, Convert.ToDouble(dn.Replace(".", ",")), Convert.ToDouble(dv.Replace(".", ","))).ToArray(); arr_data = arr_analitics; pen.DrawLinerChart(arr_analitics.Skip(buffer.Length - 1).ToArray(), y, "Прогноз"); Darbins = PredictionUpdate.darbins; }
public ProfilePrediction Put(PredictionUpdate request) { var profile = getCurrentProfileFromSession(); Prediction prediction = repo.Predictions.GetByProfileIdAndDueDateId(request.ProfileId, 1); if (request.Gender != null && !(request.Gender == "Male" || request.Gender == "Female")) throw new Exception("Gender is incorrect"); if (request.Date != null && (request.Date < new DateTime(2013, 11, 25) || request.Date > new DateTime(2014, 1, 4))) throw new Exception("Date is not valid range."); if (request.Weight != null && request.Weight != 0 && (request.Weight < 1 || request.Weight > 13)) throw new Exception("Weight is not valid range."); if (request.Length != null && request.Length != 0 && (request.Length < 15 || request.Length > 41)) throw new Exception("Length is not valid range."); prediction.PopulateWithNonDefaultValues(request); prediction = repo.Predictions.Update(prediction); if (prediction.FinishDate != null && prediction.FinishDate > DateTime.MinValue) { notify.SendCompletedGuessResultToContestCreator(profile, prediction); } return getAggregate(profile, prediction); }