private void tEnglish_Click(object sender, EventArgs e) { if (MessageBox.Show("Czy jesteś pewien, że chcesz przełączyć na język angielski?", "Zmiana języka", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly) == System.Windows.Forms.DialogResult.Yes) { var app = new AppSetting(); app.Language = Languages.en; Application.Restart(); } else { this.BringToFront(); } }
private void RunLearningProcess(bool IsResearch = false) { try { AppSetting app = new AppSetting(); if (inputDataFilename == "") { OpenDataFile(); } if (inputDataFilename == "") return; blockInterface(); NBN nbn = new NBN(app.NeuronNumber, inputDataFilename); nbn.NBN_Gain = app.Gain; nbn.NBN_Activation = app.ActivationFunction; nbn.NBN_Topography = app.TopologyType; nbn.Threshold = app.Threshold; nbn.IsClassification = app.IsClassification; nbn.IsResearchMode = IsResearch; nbn.MatLabCompareDataFolder = MatLabCompareDataFolder; string tmpMLF = MatLabCompareDataFolder; MatLabCompareDataFolder = "";//thanks got it nbn.OnErrorChange += (s, error) => { SetText(error.Format()); }; if (app.ShowConsole) { nbn.OnDebug += (s, msg) => { SetDebug(msg); }; } if (app.DontDrawChart == false) { nbn.OnChartUpdate += (s, title, x, y) => { SetChart(title, x, y); }; } if (app.ShowConsole) { console = new DebugConsole(); console.Show(); console.Hide(); } chart.Series.Clear(); nbn.settings = new NeuralNetworkSettings(app.MaxIterations, app.MU, app.MUL, app.MUH, app.Scale, app.MaxError); var result = nbn.Run(app.LearnTrials); if (tmpMLF.Length > 0) { string file = tmpMLF + "\\wyniki_z_nbn_csharp.txt"; if (File.Exists(file)) File.Delete(file); using (var w = new System.IO.StreamWriter(file, true)) { w.WriteLine("Dane: " + Path.GetFileNameWithoutExtension(result.Filename)); w.WriteLine("Liczba neuronów: " + result.Info.nn.ToString()); w.WriteLine(string.Format("Średnie RMSE uczenia: {0}", result.AverageLearnRMSE)); w.WriteLine(string.Format("Średnie RMSE testowania: {0}", result.AverageTestRMSE)); w.WriteLine(string.Format("Średnie czas uczenia: {0}", result.AverageLearnTime)); w.WriteLine(string.Format("Średnie czas testowania: {0}", result.AverageTestTime)); w.WriteLine(string.Format("Odchylenie standardowe uczenia: {0}", double.IsNaN(result.StandardDeviation) ? 0 : result.StandardDeviation)); w.WriteLine(string.Format("Odchylenie standardowe testowania: {0}", double.IsNaN(result.StandardDeviationTest) ? 0 : result.StandardDeviationTest)); w.WriteLine(string.Format("Wskaźnik sukcesu: {0}", result.SuccessRate)); } } std.Text = string.Format("Odchylenie standardowe uczenia: {0} oraz testowania: {1}", double.IsNaN(result.StandardDeviation) ? 0 : result.StandardDeviation, double.IsNaN(result.StandardDeviationTest) ? 0 : result.StandardDeviationTest); String runResult = String.Format(Resource.Inst.Get("r29"), result.AverageLearnRMSE, result.AverageTestRMSE, result.Settings.MaxError); runResult += " " + String.Format(Resource.Inst.Get("r167"), (result.AverageLearnRMSE <= result.Settings.MaxError ? Resource.Inst.Get("r169") : Resource.Inst.Get("r170"))); runResult += ", " + String.Format(Resource.Inst.Get("r168"), (result.AverageTestRMSE <= result.Settings.MaxError ? Resource.Inst.Get("r169") : Resource.Inst.Get("r170"))); try { times.Text = String.Format(String.Format(Resource.Inst.Get("r172"), result.SuccessRate)) + ", " + String.Format(Resource.Inst.Get("r171"), result.AverageLearnTime.TrimEnd(new char[] { '0', '.' }), result.AverageTestTime.TrimEnd(new char[] { '0', '.' })); } catch (Exception ex) { ex.ToLog(); } status.Text = runResult; if (app.AutoSaveLearningResults) { String file = Common.File.GetXmlFileNameForHistory(); DateTime d = DateTime.Now; History h = new History(); h.Name = String.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}", Path.GetFileNameWithoutExtension(result.Filename), d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second); h.Data = marekbar.Xml.Serialize<LearnResult>(result); h.Insert(); } if (app.ShowConsole) { console.Show(); } toolSSE.Items.Clear(); for (int i = 0; i < result.SSE.Count; i++) { toolSSE.Items.Add(Resource.Inst.Get("r182") + (i + 1).ToString()); int position = 1; foreach (var sse in result.SSE[i]) { toolSSE.Items.Add(String.Format(Resource.Inst.Get("r183"), position, Math.Round(sse,4).ToString().Replace(",","."))); position++; } } toolRMSE.Items.Clear(); for (int i = 0; i < result.RMSE.Count; i++) { toolRMSE.Items.Add(Resource.Inst.Get("r184") + (i + 1).ToString()); int position = 1; foreach (var rmse in result.RMSE[i]) { toolRMSE.Items.Add(String.Format(Resource.Inst.Get("r185"), position, Math.Round(rmse, 4).ToString().Replace(",", "."))); position++; } } } catch (Exception ex) { info = ex.ToLog().Message; } finally { unblockInterface(); } }
/// <summary> /// Save button /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void toolSave_Click(object sender, EventArgs e) { try { AppSetting s = new AppSetting(); s.MU = double.Parse(ebMU.Value.Replace('.', ',')); s.MUH = double.Parse(ebMUH.Value.Replace('.', ',')); s.MUL = double.Parse(ebMUL.Value.Replace('.', ',')); s.MaxIterations = int.Parse(ebMI.Value.Replace('.', ',')); s.MaxError = double.Parse(ebME.Value.Replace('.', ',')); s.Scale = int.Parse(ebScale.Value.Replace('.', ',')); s.ShowConsole = cbConsole.SelectedIndex == 1; s.AutoSaveLearningResults = cbAutoSave.SelectedIndex == 1; s.LearnTrials = cbTrials.SelectedIndex + 1; s.Language = (Internazional.Languages)cbLang.SelectedIndex; s.NeuronNumber = nn.SelectedIndex + 1; s.TopologyType = cbTopo.SelectedIndex; s.ActivationFunction = cbFA.SelectedIndex; s.Gain = double.Parse(tbGain.Text); s.Threshold = double.Parse(thresh.Text); s.IsClassification = is_classification.Checked; s.DontDrawChart = no_chart.Checked; } catch (Exception ex) { ex.ToLog(); status.Text = ex.Message; } }
private void tPolish_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure about switching application to Polish language?", "Language change", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly) == System.Windows.Forms.DialogResult.Yes) { var app = new AppSetting(); app.Language = Languages.pl; Application.Restart(); } else { this.BringToFront(); } }
/// <summary> /// Loading settings window event /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void SettingsWindow_Load(object sender, EventArgs e) { try { for (int i = 1; i < 1000; i++) cbTrials.Items.Add(i); AppSetting s = new AppSetting(); ebMU.Value = s.MU.ToString(); ebMUH.Value = s.MUH.ToString(); ebMUL.Value = s.MUL.ToString(); ebScale.Value = s.Scale.ToString(); ebME.Value = s.MaxError.ToString(); ebMI.Value = s.MaxIterations.ToString(); ebFolder.Value = Common.Folder.Application; cbConsole.SelectedIndex = s.ShowConsole ? 1 : 0; cbAutoSave.SelectedIndex = s.AutoSaveLearningResults ? 1 : 0; cbTrials.SelectedIndex = s.LearnTrials - 1; cbLang.SelectedIndex = (int)s.Language; nn.SelectedIndex = s.NeuronNumber - 1; cbTopo.SelectedIndex = s.TopologyType; tbGain.Text = s.Gain.ToString().Replace(",", "."); cbFA.SelectedIndex = s.ActivationFunction; thresh.Text = s.Threshold.ToString(); is_classification.Checked = s.IsClassification; no_chart.Checked = s.DontDrawChart; logsStat(); learnStat(); } catch (Exception ex) { cbConsole.SelectedIndex = 0; cbAutoSave.SelectedIndex = 1; cbTrials.SelectedIndex = 0; ex.ToLog(); } }