Exemplo n.º 1
0
        public void ExpectationMaximizationMainline()
        {
            var inputs = new double[] { 9, 10, 11, 20, 21, 22, 46, 49, 55, 57 };

            for (int i = 1; i < 6; i++)
            {
                var emMaximization = new ExpectationMaximizationImpl
                                         (inputs, mixtureCount: i);

                ExpectationMaximizationResults results = emMaximization.FindConvergedMeans();

                Console.WriteLine("---------Run {0} Results------", i);
                Console.WriteLine(results.PrettyPrint());

                Assert.IsNotNull(results);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            List <double> inputs = null;
            List <ExpectationMaximizationResults> resultsCollection =
                new List <ExpectationMaximizationResults>();

            using (var fileStream = File.Open(outputLocationFinalRun, FileMode.Create))
                using (var streamWriter = new StreamWriter(fileStream))
                {
                    inputs            = ReadInputsFromFile(InputDataFile1);
                    resultsCollection = new List <ExpectationMaximizationResults>();

                    WriteToConsoleAndFile("Processing final Test data", streamWriter);
                    for (int i = 1; i < 6; i++)
                    {
                        var emMaximization = new ExpectationMaximizationImpl
                                                 (inputs.ToArray(), mixtureCount: i);

                        ExpectationMaximizationResults results = emMaximization.FindConvergedMeans();
                        resultsCollection.Add(results);

                        WriteToConsoleAndFile(
                            String.Format("---------Run {0} Results------", i), streamWriter);
                        WriteToConsoleAndFile(results.PrettyPrint(), streamWriter);
                    }

                    WriteToConsoleAndFile(
                        String.Format(
                            "K Achieving maximum BIC Score {0}",
                            FindRunAchievingMaximumBICScore(resultsCollection)), streamWriter);

                    streamWriter.Flush();
                    fileStream.Flush();
                }

            using (var fileStream = File.Open(outputLocationAssignmentSample, FileMode.Create))
                using (var streamWriter = new StreamWriter(fileStream))
                {
                    resultsCollection.Clear();
                    inputs = ReadInputsFromFile(InputDataFile0);

                    WriteToConsoleAndFile("Processing sample test data", streamWriter);
                    for (int i = 1; i < 6; i++)
                    {
                        var emMaximization = new ExpectationMaximizationImpl
                                                 (inputs.ToArray(), mixtureCount: i);

                        ExpectationMaximizationResults results = emMaximization.FindConvergedMeans();
                        resultsCollection.Add(results);

                        WriteToConsoleAndFile(
                            String.Format("---------Run {0} Results------", i), streamWriter);
                        WriteToConsoleAndFile(results.PrettyPrint(), streamWriter);
                    }

                    WriteToConsoleAndFile(
                        String.Format(
                            "K Achieving maximum BIC Score {0}",
                            FindRunAchievingMaximumBICScore(resultsCollection)), streamWriter);
                }

            Console.ReadLine();
        }