private void addMlSettingsBoxContent() { MachineLearning.Learning.ML_Settings settingsObject = new MachineLearning.Learning.ML_Settings(); FieldInfo[] fields = settingsObject.GetType().GetFields(); for (int i = 0; i < fields.Length; i++) { Label l = new Label(); mlSettingsPanel.Controls.Add(l); l.AutoSize = true; l.Location = new System.Drawing.Point(5, 5 + ML_FIELDS_OFFSET * i); l.Name = fields[i].Name + "_label"; l.Size = new System.Drawing.Size(35, 15); l.TabIndex = i * 2; l.Text = fields[i].Name; TextBox t = new TextBox(); mlSettingsPanel.Controls.Add(t); t.Location = new System.Drawing.Point(150, 5 + ML_FIELDS_OFFSET * i); t.Name = fields[i].Name + "_textBox"; t.Size = new System.Drawing.Size(150, 20); t.TabIndex = i * 2 + 1; t.Text = fields[i].GetValue(settingsObject).ToString(); } }
private void addMlSettingsBoxContent() { MachineLearning.Learning.ML_Settings settingsObject = new MachineLearning.Learning.ML_Settings(); FieldInfo[] fields = settingsObject.GetType().GetFields(); for (int i = 0; i < fields.Length; i++) { Label l = new Label(); mlSettingsPanel.Controls.Add(l); l.AutoSize = true; l.Location = new System.Drawing.Point(5, 5 + ML_FIELDS_OFFSET * i); l.Name = fields[i].Name + "_label"; l.Size = new System.Drawing.Size(35, 15); l.TabIndex = i * 2; l.Text = fields[i].Name; TextBox t = new TextBox(); mlSettingsPanel.Controls.Add(t); t.Location = new System.Drawing.Point(150, 5 + ML_FIELDS_OFFSET * i); t.Name = fields[i].Name + "_textBox"; t.Size = new System.Drawing.Size(150, 20); t.TabIndex = i * 2 + 1; t.Text = fields[i].GetValue(settingsObject).ToString(); } }
private static void defineParameterSpace(string[] parameters, Dictionary <string, List <bool> > boolSettings, Dictionary <string, List <int> > intSettings, Dictionary <string, List <double> > doubleSettings, Dictionary <string, List <LossFunction> > lossFuncInterval, Dictionary <string, List <ScoreMeasure> > scoreMeasureInterval, Dictionary <string, List <TimeSpan> > learnTimeLimitInterval) { foreach (string parameter in parameters) { //dummy int y; double x; TimeSpan z; //setting name and values that should be within the parameter space Tuple <string, string[]> nameAndValues = extractSettings(parameter); ML_Settings referenceSetting = new ML_Settings(); System.Reflection.FieldInfo fi = referenceSetting.GetType().GetField(nameAndValues.Item1); if (fi == null) { GlobalState.logInfo.logLine("Invalid variable name: " + nameAndValues.Item1 + ". This setting will be ignored."); } else if (isBool(nameAndValues.Item2[0]) && fi.FieldType.FullName.Equals("System.Boolean")) { List <bool> toAdd = new List <bool>(); foreach (string value in nameAndValues.Item2) { toAdd.Add(toBool(value)); } boolSettings.Add(nameAndValues.Item1, toAdd); } else if (int.TryParse(nameAndValues.Item2[0], out y) && (fi.FieldType.FullName.Equals("System.Int32") || fi.FieldType.FullName.Equals("System.Int64"))) { List <int> toAdd = new List <int>(); foreach (string value in nameAndValues.Item2) { toAdd.Add(int.Parse(value)); } intSettings.Add(nameAndValues.Item1, toAdd); } else if (Double.TryParse(nameAndValues.Item2[0], out x) && fi.FieldType.FullName.Equals("System.Double")) { List <double> toAdd = new List <double>(); foreach (string value in nameAndValues.Item2) { toAdd.Add(Double.Parse(value, CultureInfo.InvariantCulture)); } doubleSettings.Add(nameAndValues.Item1, toAdd); } else if (isLossFunction(nameAndValues.Item2[0]) && fi.FieldType.FullName.Equals("MachineLearning.Learning.ML_Settings+LossFunction")) { List <LossFunction> toAdd = new List <LossFunction>(); foreach (string value in nameAndValues.Item2) { toAdd.Add(toLossFunction(value)); } lossFuncInterval[nameAndValues.Item1] = toAdd; } else if (isScoreMeasure(nameAndValues.Item2[0]) && fi.FieldType.FullName.Equals("MachineLearning.Learning.ML_Settings+ScoreMeasure")) { List <ScoreMeasure> toAdd = new List <ScoreMeasure>(); foreach (string value in nameAndValues.Item2) { toAdd.Add(toScoreMeasure(value)); } scoreMeasureInterval[nameAndValues.Item1] = toAdd; } else if (TimeSpan.TryParse(nameAndValues.Item2[0], out z) && fi.FieldType.FullName.Equals("System.TimeSpan")) { List <TimeSpan> toAdd = new List <TimeSpan>(); foreach (string value in nameAndValues.Item2) { toAdd.Add(TimeSpan.Parse(value)); } learnTimeLimitInterval[nameAndValues.Item1] = toAdd; } else { GlobalState.logInfo.logLine("Invalid setting-value pair: " + nameAndValues.Item1 + " " + string.Join(",", nameAndValues.Item2) + ". This setting will be ignored."); } } }