コード例 #1
0
        public static string binaryRelevenceData()
        {
            int baseClasses = 8;

            FilePreparation.CreateMultiLevelClassFile();

            FilePreparation.PrepareLabelFileWithLineNumber(
                Path.Combine(BaseFilePath, labelFilName),
                Path.Combine(BaseFilePath, lineNumberLabelFileName));

            FilePreparation.MergeTwoClassFileWithMultiClass(
                new string[] { Path.Combine(BaseFilePath, multiLebelFileName), Path.Combine(BaseFilePath, lineNumberLabelFileName) },
                Path.Combine(BaseFilePath, multiLevelClassFileWritename));


            for (int eachClass = 1; eachClass <= baseClasses; eachClass++)
            {
                string eachClassFileName = String.Format("{0}_{1}.txt", binaryRelBaseFileName, eachClass);
                string eachArrfFileName  = String.Format("{0}_{1}.arff", binaryRelBaseArrfFileName, eachClass);

                binaryRelevenceFeatureExterctionFile(
                    Path.Combine(BaseFilePath, bigramFromPSSM),
                    Path.Combine(BaseFilePath, eachClassFileName),
                    Path.Combine(BaseFilePath, eachArrfFileName),
                    eachClass);
            }


            //Weka.classifierTwo(
            //Path.Combine(BaseFilePath, arrfFileName),
            //Path.Combine(BaseFilePath, predictionModel));

            //Weka.classifyTest(Path.Combine(BaseFilePath, binaryRelBaseArrfFileName), baseClasses);


            string performance = String.Empty;

            string[] _classifierList = new string[] { "svm", "j48", "nb", "rf" };
            for (int loop = 0; loop < _classifierList.Length; loop++)
            {
                //performance += _classifierList[loop] + " - " + Weka.resultPrepare(Path.Combine(BaseFilePath, binaryRelBaseArrfFileName), baseClasses, _classifierList[loop]).ToString()+"\n ";
                performance += _classifierList[loop] + " - " + resultPrepareWithCrossFold(Path.Combine(BaseFilePath, binaryRelBaseArrfFileName), baseClasses, _classifierList[loop]).ToString() + "\n ";
                System.Console.WriteLine(performance);
            }
            //Weka.predictClass(Path.Combine(BaseFilePath, arrfFileName));

            return(performance);

            //Console.ReadKey();
        }
コード例 #2
0
        public static string labelPowersetData()
        {
            string currentDirectory = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));

            currentDirectory = currentDirectory.TrimEnd('\\');
            currentDirectory = currentDirectory.Remove(currentDirectory.LastIndexOf('\\') + 1);

            string BaseFilePath = Path.Combine(currentDirectory, "Files\\");
            string arrfFileName = "MultiClass_PSSMSS.arff";
            string multiLevelClassFileWithLineNumberWritename = "MultiClassWithLine.txt";
            string classFileWritename           = "finalClass.txt";
            string predictionModel              = "predictionModel";
            string classMappingFile             = "classMappingFile.txt";
            string multiLevelClassFileWritename = "MultiClass.txt";
            string bigramFromPSSM        = "BigramFromPSSM_Hasnaeen.txt";
            string binaryRelBaseFileName = "class";



            int numberOfClass = FilePreparation.MultiClassToSingleClassConverter(
                Path.Combine(BaseFilePath, multiLevelClassFileWritename),
                Path.Combine(BaseFilePath, classFileWritename),
                Path.Combine(BaseFilePath, classMappingFile),
                Path.Combine(BaseFilePath, multiLevelClassFileWithLineNumberWritename),
                Path.Combine(BaseFilePath, binaryRelBaseFileName));

            labelPowersetFeatureExterctionFile(
                Path.Combine(BaseFilePath, bigramFromPSSM),
                Path.Combine(BaseFilePath, classFileWritename),
                Path.Combine(BaseFilePath, arrfFileName),
                numberOfClass);



            string performance = String.Empty;

            string[] _classifierList = new string[] { "svm", "j48", "nb", "rf" };
            for (int loop = 0; loop < _classifierList.Length; loop++)
            {
                performance += _classifierList[loop] + " - " + resultPrepare(Path.Combine(BaseFilePath, arrfFileName), _classifierList[loop]).ToString() + "\n ";
                System.Console.WriteLine(performance);
            }
            //Weka.predictClass(Path.Combine(BaseFilePath, arrfFileName));

            return(performance);
        }