Accord.MachineLearning.DecisionTrees.DecisionTreeExpressionCreator.Create C# (CSharp) Method

Create() public method

Creates an expression for the tree.
public Create ( ) : int>>.Expression
return int>>.Expression
        public Expression<Func<double[], int>> Create()
        {
            inputs = Expression.Parameter(typeof(double[]), "input");
            label = Expression.Label(typeof(int), "return");

            var rootExpression = create(tree.Root);

            ConstructorInfo ex = typeof(ArgumentException).GetConstructor(
                new[] { typeof(string), typeof(string) });

            BlockExpression block = Expression.Block(typeof(int),
                rootExpression,
                Expression.Throw(Expression.New(ex,
                    Expression.Constant("Input contains a value outside of expected ranges."),
                    Expression.Constant("input"))),
                Expression.Label(label, Expression.Constant(0))
            );

            return Expression.Lambda<Func<double[], int>>(block, inputs);
        }

Usage Example

コード例 #1
0
ファイル: DecisionTree.cs プロジェクト: colinnuk/accord
        /// <summary>
        ///   Creates an <see cref="Expression">Expression Tree</see> representation
        ///   of this decision tree, which can in turn be compiled into code.
        /// </summary>
        ///
        /// <returns>A tree in the form of an expression tree.</returns>
        ///
        public Expression <Func <double[], int> > ToExpression()
        {
            DecisionTreeExpressionCreator compiler = new DecisionTreeExpressionCreator(this);

            return(compiler.Create());
        }
All Usage Examples Of Accord.MachineLearning.DecisionTrees.DecisionTreeExpressionCreator::Create