示例#1
0
        private void IterateThroughTypes(List <double> windowWidths, int neighborsCount)
        {
            foreach (WindowType windowType in Enum.GetValues(typeof(WindowType)))
            {
                foreach (DistanceFunctionType distanceFunctionType in Enum.GetValues(typeof(DistanceFunctionType)))
                {
                    foreach (KernelFunctionType kernelFunctionType in Enum.GetValues(typeof(KernelFunctionType)))
                    {
                        var parameters = new Parameters(
                            Entities,
                            DistancesForEachType[Convert.ToInt32(distanceFunctionType)],
                            distanceFunctionType,
                            windowType,
                            kernelFunctionType,
                            windowWidths[Convert.ToInt32(distanceFunctionType)],
                            neighborsCount);

                        var naiveFMeasure = LeaveOneOutService.CalculateFMeasureNaive(parameters);
                        NaiveFMeasures.Add(new FMeasureFromEnums(parameters, naiveFMeasure));

                        var oneHotFMeasure = LeaveOneOutService.CalculateFMeasureOneHot(parameters);
                        OneHotFMeasures.Add(new FMeasureFromEnums(parameters, oneHotFMeasure));
                    }
                }
            }
        }
示例#2
0
        public void Solve(
            List <double> windowWidths,
            int neighborsCount)
        {
            IterateThroughTypes(windowWidths, neighborsCount);

            NaiveBestFMeasure  = NaiveFMeasures.Aggregate((max, next) => max.Value > next.Value ? max : next);
            OneHotBestFMeasure = OneHotFMeasures.Aggregate((max, next) => max.Value > next.Value ? max : next);

            FindDependencies();

            foreach (var fMeasure in NaiveFMeasures)
            {
                Console.WriteLine($"{fMeasure.Parameters.WindowType}; {fMeasure.Parameters.DistanceFunctionType}; {fMeasure.Parameters.KernelFunctionType}; {fMeasure.Value}");
            }
            Console.WriteLine($">>>>>NAIVE BEST: {NaiveBestFMeasure.Parameters.WindowType}; {NaiveBestFMeasure.Parameters.DistanceFunctionType}; {NaiveBestFMeasure.Parameters.KernelFunctionType}; {NaiveBestFMeasure.Value}");
            Console.WriteLine($">>>>>NAIVE MEAN F MEASURE: {NaiveFMeasures.Average(fm => fm.Value)}");
            foreach (var fMeasure in OneHotFMeasures)
            {
                Console.WriteLine($"{fMeasure.Parameters.WindowType}; {fMeasure.Parameters.DistanceFunctionType}; {fMeasure.Parameters.KernelFunctionType}; {fMeasure.Value}");
            }
            Console.WriteLine($">>>>>ONEHOT BEST: {OneHotBestFMeasure.Parameters.WindowType}; {OneHotBestFMeasure.Parameters.DistanceFunctionType}; {OneHotBestFMeasure.Parameters.KernelFunctionType}; {OneHotBestFMeasure.Value}");
            Console.WriteLine($">>>>>ONEHOT MEAN F MEASURE: {OneHotFMeasures.Average(fm => fm.Value)}");
            Console.WriteLine();

            Console.WriteLine("------------------------------------");
            Console.WriteLine("Naive dependency");
            Console.WriteLine("------------------------------------");
            foreach (var fMeasureFromWidthOrCount in NaiveFMeasureDependency)
            {
                switch (NaiveBestFMeasure.Parameters.WindowType)
                {
                case WindowType.Fixed:
                    Console.WriteLine($"{fMeasureFromWidthOrCount.WindowWidth:N2}; {fMeasureFromWidthOrCount.Value}");
                    break;

                case WindowType.Variable:
                    Console.WriteLine($"{fMeasureFromWidthOrCount.NeighborsCount}; {fMeasureFromWidthOrCount.Value}");
                    break;

                default:
                    break;
                }
            }
            Console.WriteLine();

            Console.WriteLine("------------------------------------");
            Console.WriteLine("One Hot dependency");
            Console.WriteLine("------------------------------------");
            foreach (var fMeasureFromWidthOrCount in OneHotFMeasureDependency)
            {
                switch (OneHotBestFMeasure.Parameters.WindowType)
                {
                case WindowType.Fixed:
                    Console.WriteLine($"{fMeasureFromWidthOrCount.WindowWidth:N2}; {fMeasureFromWidthOrCount.Value}");
                    break;

                case WindowType.Variable:
                    Console.WriteLine($"{fMeasureFromWidthOrCount.NeighborsCount}; {fMeasureFromWidthOrCount.Value}");
                    break;

                default:
                    break;
                }
            }
            Console.WriteLine();
        }