public static Output ProcessInstance(Tree tree, Instance i) { if (tree.Leaf != null) { return tree.Leaf; } return ProcessInstance(tree.TreeForInstance(i), i); }
private Tree LeafForEachFeature() { // each feature is the last item var branches = new Dictionary<Feature, Tree>(); foreach (var instance in Instances) { foreach (var feature in instance.Features) { if (branches.Any(k => k.Key.Value == feature.Value)) { continue; } branches[feature] = new Tree { Leaf = instance.Output }; } } return new Tree { Branches = branches }; }