Пример #1
0
        private void CalculateFeaturesStatisticks()
        {
            int             featuresCount = Patients.First().Features.Count;
            IList <Feature> features      = GetAllFeatures();

            foreach (Feature feature in Patients.First().Features)
            {
                int i = feature.Id;
                if (Patients.First().Features.First(x => x.Id == i).Type == FeatureType.Binary)
                {
                    double featureProbability = features.Where(x => x.Id == i).Sum(x => x.Value) / Patients.Count;
                    BinaryFeaturesProbabilities.Add(i, featureProbability);
                }

                else
                {
                    for (int j = 0; j < ContinousFeaturesRanges.Buckets; j++)
                    {
                        Range  range        = ContinousFeaturesRanges.Ranges[i];
                        double featureRange = ContinousFeaturesRanges.FeatureRange(i);
                        double offsetMin    = featureRange / ContinousFeaturesRanges.Buckets * j;
                        double offsetMax    = featureRange / ContinousFeaturesRanges.Buckets * (j + 1);
                        ContinousFeatureProbability bucket = new ContinousFeatureProbability(i, range.Min + offsetMin, range.Min + offsetMax);

                        bucket.Probability = (double)features.Count(x => x.Id == i && bucket.IsInRange(x.Value)) / Patients.Count;

                        ContinousFeatureProbabilities.Add(bucket);
                    }
                }
            }
        }