public int Compute(double[] inputs, MulticlassComputeMethod method)
 {
     lock (this.Models)
     {
         var prev = this.Method;
         this.Method = method;
         int decision;
         this.Probabilities(inputs, out decision);
         this.Method = prev;
         return(decision);
     }
 }
 public int Compute(double[] inputs, MulticlassComputeMethod method, out double[] responses, out double output)
 {
     lock (this.Models)
     {
         var prev = this.Method;
         this.Method = method;
         int decision;
         responses   = this.Probabilities(inputs, out decision);
         this.Method = prev;
         output      = responses[decision];
         return(decision);
     }
 }
示例#3
0
 /// <summary>
 ///   Computes the given input to produce the corresponding output.
 /// </summary>
 /// 
 /// <param name="inputs">An input vector.</param>
 /// <param name="method">The <see cref="MulticlassComputeMethod">
 ///   multi-class classification method</see> to use.</param>
 /// <param name="output">The output of the machine. If this is a 
 ///   <see cref="IsProbabilistic">probabilistic</see> machine, the
 ///   output is the probability of the positive class. If this is
 ///   a standard machine, the output is the distance to the decision
 ///   hyperplane in feature space.</param>
 /// 
 /// <returns>The class decision for the given input.</returns>
 ///
 public int Compute(double[] inputs, MulticlassComputeMethod method, out double output)
 {
     if (method == MulticlassComputeMethod.Voting)
     {
         int[] votes;
         return computeVoting(inputs, out votes, out output);
     }
     else
     {
         double[] responses;
         return computeElimination(inputs, out responses, out output);
     }
 }
示例#4
0
        /// <summary>
        ///   Computes the given input to produce the corresponding output.
        /// </summary>
        /// 
        /// <param name="inputs">An input vector.</param>
        /// <param name="method">The <see cref="MulticlassComputeMethod">
        ///   multi-class classification method</see> to use.</param>
        /// <param name="responses">The model response for each class.</param>
        /// <param name="output">The output of the machine. If this is a 
        ///   <see cref="IsProbabilistic">probabilistic</see> machine, the
        ///   output is the probability of the positive class. If this is
        ///   a standard machine, the output is the distance to the decision
        ///   hyperplane in feature space.</param>
        /// 
        /// <returns>The decision label for the given input.</returns>
        /// 
        public int Compute(double[] inputs, MulticlassComputeMethod method, out double[] responses, out double output)
        {
            if (method == MulticlassComputeMethod.Voting)
            {
                int[] votes;
                int result = computeVoting(inputs, out votes, out output);

                responses = new double[votes.Length];
                for (int i = 0; i < responses.Length; i++)
                    responses[i] = votes[i] * (2.0 / (Classes * (Classes - 1)));

                return result;
            }
            else
            {
                return computeElimination(inputs, out responses, out output);
            }
        }
示例#5
0
 /// <summary>
 ///   Computes the given input to produce the corresponding output.
 /// </summary>
 /// 
 /// <param name="inputs">An input vector.</param>
 /// <param name="method">The <see cref="MulticlassComputeMethod">
 ///   multi-class classification method</see> to use.</param>
 /// 
 /// <returns>The class decision for the given input.</returns>
 ///
 public int Compute(double[] inputs, MulticlassComputeMethod method)
 {
     double output;
     return Compute(inputs, method, out output);
 }
        /// <summary>
        ///   Computes the given input to produce the corresponding output.
        /// </summary>
        ///
        /// <param name="inputs">An input vector.</param>
        /// <param name="method">The <see cref="MulticlassComputeMethod">
        ///   multi-class classification method</see> to use.</param>
        /// <param name="responses">The model response for each class.</param>
        ///
        /// <returns>The class decision for the given input.</returns>
        ///
        public int Compute(double[] inputs, MulticlassComputeMethod method, out double[] responses)
        {
            double output;

            return(Compute(inputs, method, out responses, out output));
        }