Пример #1
0
        public static List <double> CalculateAverageRMSE(string dirWithFiles, IEnumerable <IPredictionAlgorithm> algorithms, out double averagePredictionNum, out double averageActualPrice)
        {
            List <double> rmseValues = new List <double>();

            List <List <double> > rmseLists = InitRmseLists(algorithms.Count());

            string[] filesPath = System.IO.Directory.GetFiles(dirWithFiles);

            //IEnumerable<BasicDataset> predicted = PredictionController.Predict(filesPath[0], new MovingAverage, out IEnumerable<BasicDataset> datasets);

            int fileNum = 1;

            averagePredictionNum = 0; averageActualPrice = 0;

            foreach (string filePath in filesPath)
            {
                int alghNum = 0;

                try
                {
                    foreach (IPredictionAlgorithm algorithm in algorithms)
                    {
                        IEnumerable <BasicDataset> predicted = PredictionController.Predict(filePath, algorithm, out IEnumerable <BasicDataset> datasets);

                        datasets = datasets.OrderBy(a => a.Date);

                        averagePredictionNum += predicted.Count();

                        ++fileNum;

                        SplitSet(datasets, out IEnumerable <BasicDataset> trainingSet, out IEnumerable <BasicDataset> controlSet);

                        averageActualPrice += controlSet.Select(a => (double)a.Close).Average();

                        double rmse = GetRMSEAnother(controlSet, predicted);

                        rmseLists[alghNum++].Add(rmse);
                    }
                }
                catch
                {
                }
            }

            foreach (List <double> rmseList in rmseLists)
            {
                rmseValues.Add(rmseList.Average());
            }

            averagePredictionNum /= fileNum;
            averageActualPrice   /= fileNum;

            return(rmseValues);
        }
Пример #2
0
        private static IEnumerable <BasicDataset> GetPrediction(FileTransferRequest request)
        {
            IPredictionAlgorithm algorithm = ChosePredictionAlgorithm(request.SelectedAlgortihms);

            return(PredictionController.Predict(request.FileBytes, algorithm));
        }