/// <summary>
        /// Create a prediction based on the learned Theta values and the supplied test item.
        /// </summary>
        /// <param name="y">Training record</param>
        /// <returns></returns>
        public override double Predict(Vector y)
        {
            var tempy = PolynomialFeatures > 0 ? PreProcessing.FeatureDimensions.IncreaseDimensions(y, PolynomialFeatures) : y;

            tempy = tempy.Insert(0, 1.0);
            return(LogisticFunction.Compute((tempy * Theta).ToDouble()) >= 0.5 ? 1d : 0d);
        }
Exemple #2
0
        /// <summary>
        /// Computes the probability of the prediction being True.
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public double PredictRaw(Vector x)
        {
            x = IncreaseDimensions(x, this.PolynomialFeatures);

            this.Preprocess(x);

            return(LogisticFunction.Compute(x.Insert(0, 1.0, false).Dot(Theta)));
        }
Exemple #3
0
        /// <summary>Projects vector into a logistic kernel space.</summary>
        /// <param name="m">Kernel Matrix.</param>
        /// <param name="x">Vector in original space.</param>
        /// <returns>Vector in logistic kernel space.</returns>
        public Vector Project(Matrix m, Vector x)
        {
            var K = Vector.Zeros(m.Rows);

            for (var i = 0; i < K.Length; i++)
            {
                var xy = m[i].Dot(x);
                K[i] = LogisticFunction.Compute(Lambda * xy);
            }

            return(K);
        }