private DoubleRange computeInterval(double[] input, int numberOfSamples, double percent, double se)
        {
            double      y   = linear.Transform(input);
            double      df  = GetDegreesOfFreedom(numberOfSamples);
            var         t   = new TTest(estimatedValue: y, standardError: se, degreesOfFreedom: df);
            DoubleRange lci = t.GetConfidenceInterval(percent);
            DoubleRange nci = new DoubleRange(linkFunction.Inverse(lci.Min), linkFunction.Inverse(lci.Max));

            return(nci);
        }
        public double Compute(double[] input)
        {
            double sum = coefficients[0];

            for (int i = 1; i < coefficients.Length; i++)
            {
                sum += input[i - 1] * coefficients[i];
            }
            return(linkFunction.Inverse(sum));
        }
Exemple #3
0
        /// <summary>
        ///   Computes the given input to produce the corresponding output.
        /// </summary>
        ///
        /// <remarks>
        ///   For a binary decision problem, the decision for the negative
        ///   or positive class is typically computed by taking the sign of
        ///   the machine's output.
        /// </remarks>
        ///
        /// <param name="inputs">An input vector.</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 virtual int Compute(double[] inputs, out double output)
        {
            output = threshold;

            if (supportVectors == null)
            {
                for (int i = 0; i < weights.Length; i++)
                {
                    output += weights[i] * inputs[i];
                }
            }
            else
            {
                for (int i = 0; i < supportVectors.Length; i++)
                {
                    double sum = 0;
                    for (int j = 0; j < inputs.Length; j++)
                    {
                        sum += supportVectors[i][j] * inputs[j];
                    }
                    output += weights[i] * sum;
                }
            }

            if (IsProbabilistic)
            {
                output = linkFunction.Inverse(output);
                return(output >= 0.5 ? +1 : -1);
            }

            return(output >= 0 ? +1 : -1);
        }