Accord.MachineLearning.DecisionTrees.RandomForest.Decide C# (CSharp) Method

Decide() public method

Computes a class-label decision for a given input.
public Decide ( double input ) : int
input double The input vector that should be classified into /// one of the possible classes.
return int
        public override int Decide(double[] input)
        {
            int[] responses = new int[NumberOfOutputs];
            Parallel.For(0, trees.Length, i =>
            {
                int j = trees[i].Decide(input);
                Interlocked.Increment(ref responses[j]);
            });

            return responses.ArgMax();
        }
    }

Usage Example

        /// <summary>
        /// <inheritdoc />
        /// </summary>
        public override void Run()
        {
            var inputs = data.GetSelectedInput(features);

            ClassificationOutputs = forest.Decide(inputs);
        }