Пример #1
0
        public static double WeightUsingVariance(IFeatureCollectionWrapper <FeatureBase> featureValues)
        {
            if (featureValues.Count() < 2)
            {
                return(1);
            }

            var variance = featureValues.Variance(feature => feature.FeatureValue);

            if (variance.Equals(0))
            {
                return((double)1 / featureValues.Count());
            }
            return(1 / variance);
        }
Пример #2
0
        public static double First3BEqualMetric(FeatureBase value, IFeatureCollectionWrapper <FeatureBase> featureValues)
        {
            if (value.FeatureValue.Equals(-1.0) || !featureValues.Any())
            {
                return(0);
            }
            var tmpTrue  = featureValues.Count(x => x.FeatureValue.Equals(1.0));
            var tmpFalse = featureValues.Count(x => x.FeatureValue.Equals(0.0));

            Console.WriteLine("3Bequal " + tmpTrue + " " + tmpFalse + " FeatureValue: " + value.FeatureValue);
            if ((tmpTrue > tmpFalse && value.FeatureValue.Equals(1.0)) || (tmpTrue < tmpFalse && value.FeatureValue.Equals(0.0)))
            {
                return(0.0);
            }

            return(1.0);
        }
Пример #3
0
        public override void ComputeFeatureForProtocolModel(IFeatureCollectionWrapper <FeatureBase> featureValues)
        {
            var trueValues  = featureValues.Count(feature => feature.FeatureValue.Equals(1.0));
            var falseValues = featureValues.Count(feature => feature.FeatureValue.Equals(0.0));

            this.FeatureValue = (trueValues > falseValues)? 1 : 0;

            if (trueValues == 0 || falseValues == 0)
            {
                this.Weight = 1;
            }                                                            // /(double)Math.Sqrt(trueValues+falseValues); }
            else if (trueValues < falseValues)
            {
                this.Weight = 1 - (trueValues / (double)falseValues);
            }
            else
            {
                this.Weight = 1 - (falseValues / (double)trueValues);
            }
        }
Пример #4
0
        public static double WeightProbabilityMetric(IFeatureCollectionWrapper <FeatureBase> trainingFeatureVector)
        {
            var mostVal = (from i in trainingFeatureVector
                           group i by i.FeatureValue
                           into grp
                           orderby grp.Count() descending
                           select grp).First();

            var result = (double)mostVal.Count() / trainingFeatureVector.Count();

            //Console.WriteLine("Weight: " + result + "\n" + "Count " + trainingFeatureVector.Count());
            return(result);
        }