public static DecisionTree Build(List <PointXD> data) { DecisionTree tree = new DecisionTree(); data.ForEach(point => tree.HandlePoint(point)); tree.Simplify(); return(tree); }
private DecisionTree HandlePoint(PointXD point, int paramCount = 0) { if (paramCount == point.Count) { Answer = point.Class; return(this); } Question = paramCount; object param = point.Attributes[paramCount]; DecisionTree tree = Branches.ContainsKey(param) ? Branches[param] : new DecisionTree(); Branches[param] = tree.HandlePoint(point, ++paramCount); return(this); }