Exemple #1
0
        public static StatisticalResultCsv[] AttachCompactness(AlgorithmCsv algorithm, DatasetCsv dataset)
        {
            List <StatisticalResultCsv> final_results = new List <StatisticalResultCsv>();
            double best_sr        = 0;
            double min_compact    = 0;
            int    min_compact_at = 0;

            string current_folder = $"{Config.WorkingFolder}\\{algorithm.Name}\\{dataset.Name}\\";
            var    dataType       = FeatureTypeExtension.FromString(dataset.Feature);

            PairwiseComparisonCsv[] pairwiseResults = CsvContext.ReadFile <PairwiseComparisonCsv>(current_folder + Config.PairwiseComparisonCsv);
            if (pairwiseResults.Length == 0)
            {
                return(OutputResults(final_results, algorithm.Name, dataset.Name));
            }
            best_sr     = pairwiseResults[0].significant_rate;
            min_compact = GetCompactness(current_folder + "\\individuals\\" + pairwiseResults[0].File, dataset);
            PairwiseComparisonCsv[] best_pairwiseResults = pairwiseResults.Where(c => c.significant_rate == best_sr).ToArray();

            for (int i = 0; i < best_pairwiseResults.Length; i++)
            {
                //double compact =
                StatisticalResultCsv finalResult = new StatisticalResultCsv();
                finalResult.DataType = dataType.ToString();
                finalResult.Method   = algorithm.Name;
                DatasetCsvToFinalCsv(dataset, finalResult);
                PairCsvToFinalCsv(best_pairwiseResults[i], finalResult);
                finalResult.Compactness = GetCompactness(current_folder + "\\individuals\\" + best_pairwiseResults[i].File, dataset);
                if (finalResult.Compactness < min_compact)
                {
                    min_compact    = finalResult.Compactness;
                    min_compact_at = i;
                }
                final_results.Add(finalResult);
            }
            final_results[min_compact_at].Best = true;

            for (int i = best_pairwiseResults.Length; i < best_pairwiseResults.Length + 5 && i < pairwiseResults.Length; i++)
            {
                StatisticalResultCsv finalResult = new StatisticalResultCsv();
                finalResult.DataType = dataType.ToString();
                finalResult.Method   = algorithm.Name;
                DatasetCsvToFinalCsv(dataset, finalResult);
                PairCsvToFinalCsv(pairwiseResults[i], finalResult);
                finalResult.Compactness = GetCompactness(current_folder + "\\individuals\\" + pairwiseResults[i].File, dataset);
                final_results.Add(finalResult);
            }

            return(OutputResults(final_results, algorithm.Name, dataset.Name));
        }
Exemple #2
0
        private static double GetCompactness(string labels_file, DatasetCsv dataset)
        {
            var dataType = FeatureTypeExtension.FromString(dataset.Feature);

            switch (dataType)
            {
            case FeatureType.Reactivity:
                return(GetCompactnessByReactivity(labels_file, dataset));

            case FeatureType.RnaDistance:
                return(GetCompactnessByRnaDistance(labels_file, dataset));

            default:
                throw new DataTypeNotSupportedException();
            }
        }
Exemple #3
0
        public static StatisticalResultCsv[] RunIndividual(AlgorithmCsv algorithm, DatasetCsv dataset, int k, bool runScript)
        {
            List <StatisticalResultCsv> finalResults = new List <StatisticalResultCsv>();

            FeatureType dataType = FeatureTypeExtension.FromString(dataset.Feature);

            if (runScript)
            {
                //ProcessExtension.Run("python", $"\"{Config.WorkingFolder}{algorithm.Script}\" {dataset.Name} 10 100");
                ProcessExtension.RunScript($"{Config.WorkingFolder}{algorithm.Script}", $"{dataset.Name} 10 100 {k}");
                //onewan ANOVA
                ProcessExtension.Run("python", $"\"{Config.WorkingFolder}{Config.JobOnewayPy}\" {algorithm.Name} {dataset.Name}");
                //pairwise comparison
                ProcessExtension.Run("RScript", $"\"{Config.WorkingFolder}{Config.JobPairwiseComparisonR}\" {algorithm.Name} {dataset.Name}");
            }

            //compactness

            string folder = $"{Config.WorkingFolder}{algorithm.Name}\\{dataset.Name}\\";

            if (!Directory.Exists(folder))
            {
                throw new FileNotFoundException();
            }

            switch (dataType)
            {
            case FeatureType.Reactivity:
                finalResults.AddRange(CSCompactness.AttachCompactness(algorithm, dataset));
                break;

            case FeatureType.RnaDistance:
                finalResults.AddRange(CSCompactness.AttachCompactness(algorithm, dataset));
                break;
            }


            return(finalResults.ToArray());
        }