public double GetFeatureFieldGrade(int feature, int fieldindex)
        {
            double finalgrade = 0;

            if (fieldindex < 0)
            {
                return(0);
            }
            SingleFieldStatistics Field = fieldList.Where(a => a.index == fieldindex).FirstOrDefault();
            double tempgrade            = 0;
            double CountResult          = fieldList.Where(a => !a.Equals(Field)).SelectMany(a => a.Features).Count() + notAName.Features.Count;



            double FieldmaxSTD = Field.GetAverge(feature) + Field.GetSTD(feature);
            double FieldminSTD = Field.GetAverge(feature) - Field.GetSTD(feature);

            foreach (SingleFieldStatistics singlefield in fieldList)
            {
                // tempgrade = Math.Abs(Field.GetAverge(feature) - singlefield.GetAverge(feature)) - (Field.GetSTD(feature) + singlefield.GetSTD(feature)) * singlefield.Features.Count() / CountResult;
                tempgrade += singlefield.Features.Select(a => a[feature]).Select(a => a < FieldminSTD ? 1 : (a > FieldmaxSTD) ? 1 : 0).Sum();

                // finalgrade += tempgrade > 0 ? tempgrade : 0;
            }
            tempgrade += notAName.Features.Select(a => a[feature]).Select(a => a < FieldminSTD ? 1 : (a > FieldmaxSTD) ? 1 : 0).Sum();
            // tempgrade = Math.Abs(Field.GetAverge(feature) - notAName.GetAverge(feature)) - (Field.GetSTD(feature) + notAName.GetSTD(feature)) * notAName.Features.Count() / CountResult;
            // finalgrade += tempgrade > 0 ? tempgrade : 0;
            finalgrade            = Math.Round(tempgrade / CountResult, 2) * 100;
            Field.Grades[feature] = finalgrade;
            return(finalgrade);
        }
        public Histograms GetFeatureFieldHistogram(double interval, int feature, SingleFieldStatistics field)
        {
            var maxValue    = fieldList.SelectMany(a => a.Features).Select(x => x[feature]).Max();
            var maxnogolden = notAName.Features.Select(x => x[feature]).Max();

            maxValue = Math.Max(maxValue, maxnogolden);

            //   var maxValue = field.Features.Select(x => x[feature]).Max();

            var histogram = new Histograms(10, maxValue);

            foreach (var featureGrade in field.Features.Select(x => x[feature]))
            {
                histogram.Add(featureGrade);
            }

            double newMax       = histogram.RemoveEdgeMax();
            var    Newhistogram = new Histograms(10, newMax);

            foreach (var featureGrade in field.Features.Select(x => x[feature]))
            {
                Newhistogram.Add(featureGrade);
            }

            return(Newhistogram);
        }
 public void AddModelFeatures(double[] features, int FieldIndex)
 {
     if (FieldIndex < 0)
     {
         notAName.AddFeature(features);
     }
     else
     {
         SingleFieldStatistics field = fieldList.Where(a => a.index == FieldIndex).FirstOrDefault();
         if (field == null)
         {
             return;
         }
         field.AddFeature(features);
     }
 }
 public FeatureStatistics()
 {
     fieldList = new List <SingleFieldStatistics>();
     notAName  = new SingleFieldStatistics("", -1);
 }