예제 #1
0
        public string BuildCandlePatternDeals()
        {
            WekaUtils.Instance.WriteLog("Now BuildCandlePatternDeals");

            var    cp         = TestParameters2.CandidateParameter;
            string resultFile = TestParameters.GetBaseFilePath(string.Format("IncrementTest_{0}_{1}_{2}.txt",
                                                                             cp.MainSymbol, "CandlePattern", cp.MainPeriod));

            if (File.Exists(resultFile))
            {
                return(string.Empty);
            }

            string txtFileName = TestParameters.GetBaseFilePath(string.Format("{0}_{1}_{2}.txt",
                                                                              cp.MainSymbol, "CandlePattern", cp.MainPeriod));

            System.IO.File.Delete(txtFileName);
            if (!File.Exists(txtFileName))
            {
                bool ret = GenerateCandlePatterns(txtFileName);
                if (!ret)
                {
                    return(string.Empty);
                }
            }

            string arffFileName = TestParameters.GetBaseFilePath(string.Format("{0}_{1}_{2}.arff",
                                                                               cp.MainSymbol, "CandlePattern", cp.MainPeriod));

            if (!System.IO.File.Exists(arffFileName))
            {
                GenerateArff(arffFileName, txtFileName);
            }

            weka.core.Instances allInstances = WekaUtils.LoadInstances(arffFileName);

            //FilterInstances(allInstances);
            WekaUtils.SaveInstances(allInstances, arffFileName);

            int n = (int)(24 / TestParameters2.MainPeriodOfHour);

            n = TestParameters2.nPeriod;
            return(TestManager.IncrementTest(allInstances, () =>
            {
                return WekaUtils.CreateClassifier(typeof(MinDistanceClassifier));
                //return WekaUtils.CreateClassifier(typeof(weka.classifiers.lazy.IBk));
            }, "1,2,3,4", resultFile, n));
        }