/// <summary>Generates.</summary> /// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception> /// <param name="X">The Matrix to process.</param> /// <param name="y">The Vector to process.</param> /// <returns>An IModel.</returns> public override IModel Generate(Matrix X, Vector y) { if (Descriptor == null) throw new InvalidOperationException("Cannot build decision tree without type knowledge!"); this.Preprocess(X); var tree = new Tree(); //var n = BuildUglyTree(x, y, Depth, new List<int>(x.Cols)); tree.Root = BuildTree(X, y, Depth, new List<int>(X.Cols), tree); // have to guess something.... // especially when automating // the thing in a Learner // this only happens if it is something // it has never seen. if (Hint == double.Epsilon) Hint = y.GetRandom(); // flip a coin... return new DecisionTreeModel { Descriptor = Descriptor, NormalizeFeatures = NormalizeFeatures, FeatureNormalizer = FeatureNormalizer, FeatureProperties = FeatureProperties, Tree = tree, Hint = Hint }; }