コード例 #1
0
        public ISelectionCriterion CreateSelectionCriterion(SelectionCriterionType criterionType)
        {
            switch (criterionType)
            {
            case SelectionCriterionType.MaximumLikelihood:
            {
                return(new MaximumLikelihoodSelectionCriterion());
            }

            case SelectionCriterionType.MaximumMutialInformation:
            {
                return(new MaximumMutialInformationSelectionCriterion());
            }

            case SelectionCriterionType.LogMaximumMutialInformation:
            {
                return(new LogMaxMutialInformationSelectionCriterion());
            }

            default:
            {
                throw new NotImplementedException("SelectionCriterionType is not supported");
            }
            }
        }
コード例 #2
0
        public IModelSelector CreateModelSelector(ModelSelectorType selectorType, SelectionCriterionType criterionType)
        {
            ISelectionCriterion selectionCriterion = _selectionCriterionFactory.CreateSelectionCriterion(criterionType);

            switch (selectorType)
            {
            case ModelSelectorType.Segment:
            {
                return(new SegmentHsmModelSelector(selectionCriterion, _segmentSize));
            }

            case ModelSelectorType.Simple:
            {
                return(new SimpleHsmModelSelector(selectionCriterion));
            }

            default:
            {
                throw new NotImplementedException("ModelSelectorType is not supported");
            }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: mzhdanova/research
        private static void RunInSelectionMode()
        {
            bool ifExit = false;

            while (!ifExit)
            {
                Console.WriteLine(
                    "Please, specify analysis parameters");
                Console.WriteLine(
                    "Please, specify type of model selection criterion as a number from the list:\r\n" +
                    " 0 - Maximum likelihood; \r\n" +
                    " 1 - Maximum mutial information; \r\n" +
                    " 2 - Logarithm maximum mutial information");

                SelectionCriterionType selectionCriterionType = ParseSelectionCriterionType(Console.ReadLine());

                Console.WriteLine(
                    "Please, specify model selector type as a number from the list:\r\n" +
                    " 0 - Simple; \r\n" +
                    " 1 - Segment");

                ModelSelectorType modelSelectorType = ParseModelSelectorType(Console.ReadLine());

                int segmentSize = 100;
                if (modelSelectorType == ModelSelectorType.Segment)
                {
                    Console.WriteLine(
                        "Enter segment size");
                    segmentSize = int.Parse(Console.ReadLine());
                }

                string pathToModelsFolder = null;
                while (pathToModelsFolder == null)
                {
                    Console.WriteLine(
                        "Specify path to models directory:");
                    pathToModelsFolder = Console.ReadLine();
                }

                string[] files = Directory.GetFiles(pathToModelsFolder, "*.json", SearchOption.AllDirectories);
                Dictionary <string, string> jsonModelsToNames = files.ToDictionary(f => f, f => ParseModelFile(f));

                Console.WriteLine(
                    "Specify path to sequence file:");
                List <int> sequence = null;

                while (sequence == null)
                {
                    Console.WriteLine(
                        "Specify path to sequence file:");
                    string pathToFile = Console.ReadLine();
                    sequence = ParseSequenceFile(pathToFile);
                }

                Console.WriteLine("Starting selection");
                SelectionManager manager = new SelectionManager(segmentSize);
                SelectionResult  result  = manager.Select(jsonModelsToNames, sequence);
                if (result.HasErrors())
                {
                    Console.WriteLine("Selection failed due to the following errors:" + result.Errors);
                }
                else
                {
                    Console.WriteLine("The model selected according to the chosen criterion is " + result.Value);
                }

                Console.WriteLine("Do you want to continue? (y/n)");
                ifExit = !ParseBoolean(Console.ReadLine());
            }
            Console.WriteLine("Press Ctrl+C to exit...");
        }