private void button4_Click(object sender, EventArgs e) { button2.Enabled = false; label2.Enabled = false; numericUpDown1.Enabled = false; button3.Enabled = false; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Files|*.dat"; DialogResult result = openFileDialog1.ShowDialog(); BinaryFormatter formatter = new BinaryFormatter(); if (result == DialogResult.OK) { using (FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open)) { ExternalForest extForest = (ExternalForest)formatter.Deserialize(fs); forest = extForest.forest; codifier = extForest.codifier; attributes = extForest.attributes; target_attribute = extForest.target_attribute; } ForestForm forest_form = new ForestForm(this); forest_form.Show(); forest_form.label1.Text = "The forest loaded!"; } }
public ForestForm(Form1 f1) { codifier = f1.codifier; forest = f1.forest; attributes = f1.attributes; target_attribute = f1.target_attribute; InitializeComponent(); }
public DesicionForm(ForestForm f) { forest = f.forest; codifier = f.codifier; attributes = f.attributes; target_attribute = f.target_attribute; InitializeComponent(); }
public ExternalForest( DecisionForest _forest, Dictionary <string, Dictionary <double, string> > _codifier, AttributeVariable[] _attributes, AttributeVariable _target_attribute) { forest = _forest; codifier = _codifier; attributes = _attributes; target_attribute = _target_attribute; }
private void button3_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; this.Enabled = false; forest = new DecisionForest(instances, target_attribute, attributes, Convert.ToInt32(numericUpDown1.Text)); this.Enabled = true; this.Cursor = Cursors.Default; ForestForm forest_form = new ForestForm(this); forest_form.Show(); forest_form.label1.Text = "The forest has been built!"; forest_form.label1.Text += "\nF-Measure is " + Math.Round(Analysis.FMeasure(instances, forest, target_attribute), 2); }
private static void CreateRFStat(string trainPath, string testPath, string ids, string target) { using (var sw = new StreamWriter(new FileStream("rfstat.csv", FileMode.Create, FileAccess.Write))) { sw.WriteLine("n;d;auc"); double StartCoeff = 0.01; string sd = ConfigReader.Read("StartCoeff"); if (sd != null) { StartCoeff = double.Parse(sd.Replace(',', '.'), CultureInfo.InvariantCulture); } double Delta = 0.05; string sdl = ConfigReader.Read("Delta"); if (sdl != null) { Delta = double.Parse(sdl.Replace(',', '.'), CultureInfo.InvariantCulture); } Logger.Log("StartCoeff = " + StartCoeff); Logger.Log("Delta = " + Delta); for (; StartCoeff <= 1; StartCoeff += Delta) { var cls = new DecisionForest(); cls.LoadData(); cls.RfCoeff = StartCoeff; var result = cls.Build(); foreach (int n in result.ResDict.Keys) { sw.WriteLine(n + ";" + StartCoeff.ToString("F03") + ";" + result.ResDict[n].AUC.ToString("F06")); sw.Flush(); } } } }
private static void CreateDepStat(string trainPath, string testPath, string ids, string target, string depstatPath, string measureField) { var fmngr = new FactorManager(); fmngr.Load(depstatPath, target, measureField); var fdList = new List <double>(); fdList.Add(0); fdList.Add(0.5); fdList.Add(1); fdList.Add(1.5); fdList = fdList.OrderByDescending(c => c).ToList(); var tdList = new List <double>(fmngr.GetTargetValues()); tdList = tdList.OrderByDescending(c => c).ToList(); using (var sw = new StreamWriter(new FileStream("depstat.csv", FileMode.Create, FileAccess.Write))) { sw.WriteLine("td;fd;cnt;last_auc;best_auc;vars;measure"); var countedDict = new Dictionary <string, ClassifierResult>(); foreach (double td in tdList) { foreach (double fd in fdList) { try { fmngr.TargDep = td; fmngr.FactorDep = fd; fmngr.SelectFactors(); var factors = fmngr.VisibleFactors; Array.Sort(factors); string vstr = string.Join("@", factors); if (!countedDict.ContainsKey(vstr)) { var cls = new DecisionForest(); var fdict = factors.ToDictionary(c => c); foreach (string variable in fmngr.FactorDict.Keys) { if (!fdict.ContainsKey(variable)) { cls.AddDropColumn(variable); } } cls.LoadData(); var result = cls.Build(); countedDict.Add(vstr, result); } else { Logger.Log("skipping..."); } sw.WriteLine(fmngr.TargDep.ToString("F06") + ";" + fmngr.FactorDep.ToString("F06") + ";" + factors.Length + ";" + countedDict[vstr].LastResult.AUC + ";" + countedDict[vstr].BestResult.AUC + ";" + vstr + ";" + measureField); sw.Flush(); Logger.Log("td=" + td.ToString("F06") + "; fd=" + fd.ToString("F06") + "; cnt=" + factors.Length + ";" + countedDict[vstr].LastResult.AUC); } catch (Exception e) { Logger.Log(e); } } } } }
public ForestView(ForestForm f) { forest = f.forest; codifier = f.codifier; InitializeComponent(); }