예제 #1
0
        /// <summary>
        /// Estimated closeness of given point to given classes
        /// </summary>
        public override double CalculateClassScore(double[] obj, Class cls)
        {
            var score  = 0.0D;
            var dim    = DataDim;
            var useMin = UseKernelMinValue;
            var min    = KernelMinValue;

            foreach (var pData in TrainingSample.Where(d => d.Value.Equals(cls)))
            {
                var data = pData.Key;

                var p = 0.0D;
                for (int i = 0; i < dim; i++)
                {
                    var h = (m_Hs != null) ? m_Hs[i] : H;
                    var r = (obj[i] - data[i]) / h;
                    var v = Kernel.Value(r) / h;
                    if (Math.Abs(v) < min && useMin)
                    {
                        v = min;
                    }
                    p += Math.Log(v);
                }

                score += p;
            }

            score += PriorProbs[cls.Value];

            return(score);
        }
예제 #2
0
        /// <summary>
        /// Estimated closeness of given point to given classes
        /// </summary>
        public override double CalculateClassScore(double[] obj, Class cls)
        {
            var dim    = DataDim;
            var p      = 0.0D;
            var y      = 0.0D;
            var my     = ClassHist[cls.Value];
            var useMin = UseKernelMinValue;
            var min    = KernelMinValue;

            for (int i = 0; i < dim; i++)
            {
                foreach (var pData in TrainingSample.Where(d => d.Value.Equals(cls)))
                {
                    var data = pData.Key;
                    var r    = (obj[i] - pData.Key[i]) / H;
                    p += Kernel.Value(r);
                }
                p = p / (H * my);
                if (Math.Abs(p) < min && useMin)
                {
                    p = min;
                }
                y += Math.Log(p);
                p  = 0.0D;
            }

            y += PriorProbs[cls.Value];

            return(y);
        }
예제 #3
0
        /// <summary>
        /// Estimates closeness of given point to given classes
        /// </summary>
        public override double CalculateClassScore(double[] obj, Class cls)
        {
            var score = 0.0D;

            foreach (var pData in TrainingSample.Where(d => d.Value.Equals(cls)))
            {
                var r = Metric.Dist(pData.Key, obj) / H;
                score += Kernel.Value(r);
            }

            score = Math.Log(score) + PriorProbs[cls.Value];

            return(score);
        }
예제 #4
0
        /// <summary>
        /// Estimated proximity of given point to given classes
        /// </summary>
        public override double CalculateClassScore(double[] obj, Class cls)
        {
            var dim = TrainingSample.GetDimension();
            var p   = PriorProbs[cls.Value];
            var ds  = m_DistributionParameters[cls.Value];

            foreach (var pData in TrainingSample.Where(d => d.Value.Equals(cls)))
            {
                var data = pData.Key;

                for (int i = 0; i < dim; i++)
                {
                    m_Distribution.Params = ds[i];
                    var value = m_Distribution.LogValue(obj[i]);

                    p += value;
                }
            }

            return(p);
        }