Example #1
0
        public List <KeyValuePair <string, double> > Rank(List <T> X, T rec)
        {
            List <KeyValuePair <string, double> > ranks = new List <KeyValuePair <string, double> >();

            int sample_count    = X.Count;
            int theta_dimension = sample_count + 1;

            foreach (string class_label in mClassFieldLabels)
            {
                double[] theta = mTheta[class_label];

                double z = theta[0];
                for (int d2 = 1; d2 < theta_dimension; ++d2)
                {
                    z += (theta[d2] * mKernel.Calc(rec.Data, X[d2 - 1].Data));
                }
                ranks.Add(new KeyValuePair <string, double>(class_label, z));
            }

            ranks.Sort((s1, s2) =>
            {
                return(s2.Value.CompareTo(s1.Value));
            });

            return(ranks);
        }
Example #2
0
        public override double Evaluate(double[] theta)
        {
            double J = 0;

            for (int i = 0; i < mSampleCount; ++i)
            {
                double z = theta[0];
                for (int d2 = 1; d2 < mDimensionCount; ++d2)
                {
                    z += (theta[d2] * mKernel.Calc(mDataSet[i].Data, mDataSet[d2 - 1].Data));
                }

                J += mC * (mY[i] * cost1(z) + (1 - mY[i]) * cost0(z));
            }

            for (int d = 0; d < mDimensionCount; ++d)
            {
                J += (theta[d] * theta[d] / 2);
            }

            //Console.WriteLine("J: {0}", J);
            return(J);
        }