private void CalculateResult_Click(object sender, RoutedEventArgs e) { if (TrainModel.Count < 1) { return; } string[] Names = new string[TrainModel.Count]; for (int i = 0; i < Names.Length; i++) { Names[i] = TrainModel[i].Name; } var epw = new EnterParametersWindow(Names); epw.ShowDialog(); if (epw.DialogResult == true) { var inputs = new List <double>(); foreach (string cur in epw.Table.Rows[0].ItemArray) { inputs.Add(double.Parse(cur, CultureInfo.InvariantCulture)); } //MessageBox.Show($"Предполагаемый доход: {regression.Transform(inputs.ToArray()):F2}"); var PresentationWindow = new ResultPresentationWindow("Предполагаемый доход:", regression.Transform(inputs.ToArray())); PresentationWindow.ShowDialog(); epw.Table?.Dispose(); } }
private void CalculateParameter_Click(object sender, RoutedEventArgs e) { var ListOfActive = new List <string>(); for (int i = 0; i < TrainModel.Count; i++) { ListOfActive.Add(TrainModel[i].Name); } if (ListOfActive.Count < 1) { return; } var chpw = new ChooseParameterWindow(ListOfActive.ToArray()); chpw.ShowDialog(); if (chpw.DialogResult != true) { return; } int SelectedIndex = chpw.Names.SelectedIndex; ListOfActive.RemoveAt(SelectedIndex); ListOfActive.Add("Доход"); var epw = new EnterParametersWindow(ListOfActive.ToArray()); epw.ShowDialog(); if (epw.DialogResult != true) { return; } var parameters = new List <double>(); foreach (string cur in epw.Table.Rows[0].ItemArray) { parameters.Add(double.Parse(cur, CultureInfo.InvariantCulture)); } double ValueOnLeftSide = parameters[parameters.Count - 1]; parameters[parameters.Count - 1] = 1; var coefficents = regression.Weights.ToList(); coefficents.Add(regression.Intercept); coefficents.RemoveAt(SelectedIndex); for (int i = 0; i < parameters.Count; i++) { ValueOnLeftSide -= parameters[i] * coefficents[i]; } double res = ValueOnLeftSide / regression.Weights[SelectedIndex]; //MessageBox.Show($"Предполагаемое необходимое значение параметра \"{TrainModel[SelectedIndex].Name}\": {res}"); var PresentationWindow = new ResultPresentationWindow("Предполагаемое необходимое значение параметра \"{TrainModel[SelectedIndex].Name}\":", res); PresentationWindow.ShowDialog(); epw.Table?.Dispose(); }