MCAEmotiv.Classification.Example.WithFeatures C# (CSharp) Method

WithFeatures() public method

Efficiently returns an identical example except with only the features at the indices specified by the argument. No copying of features is performed.
public WithFeatures ( IArrayView featureIndices ) : Example
featureIndices IArrayView
return Example
        public Example WithFeatures(IArrayView<int> featureIndices)
        {
            return new Example(this.Class, this.Features.Select(featureIndices));
        }

Usage Example

Example #1
0
        /// <summary>
        /// Predicts the binary class of the binary example using the weighted vote of each weak learner
        /// </summary>
        protected override int PredictBinary(Example binaryExample, out double confidence)
        {
            confidence = 1.0;
            double weightedVote = 0;

            for (int i = 0; i < this.weakLearners.Length; i++)
            {
                weightedVote += this.alphas[i] *
                                this.weakLearners[i].Predict(binaryExample.WithFeatures(this.weakLearnerFeatures[i]));
            }

            if (weightedVote == 0)
            {
                return(this.NegativeExampleValue);
            }
            return(Math.Sign(weightedVote));
        }
All Usage Examples Of MCAEmotiv.Classification.Example::WithFeatures