예제 #1
0
        public static void SaveDataSet(MeteoDataSet dataSet, string path, LabelizationMode labelizationMode)
        {
            var    groupSize     = dataSet.TrainData[0].Inputs.Count;
            string directoryPart = $@"{path}PreparedData\{groupSize}\Labelization_{labelizationMode.ToString()}\";
            string filePart      = $"{dataSet.Season.ToString()}_{DS_TYPE}.csv";
            var    pathToSave    = directoryPart + filePart;

            Directory.CreateDirectory(directoryPart);
            using (StreamWriter sw = new StreamWriter(pathToSave.Replace(DS_TYPE, "Train")))
            {
                sw.WriteLine(MeteoData.GetHeader(groupSize));
                foreach (var gr in dataSet.TrainData)
                {
                    sw.WriteLine(gr.ToString(labelizationMode));
                }
            }
            using (StreamWriter sw = new StreamWriter(pathToSave.Replace(DS_TYPE, "Test")))
            {
                sw.WriteLine(MeteoData.GetHeader(groupSize));
                foreach (var gr in dataSet.TestData)
                {
                    sw.WriteLine(gr.ToString(labelizationMode));
                }
            }
        }
예제 #2
0
        static string path = $@"C:\Users\Mateusz\Desktop\Meteodata\";  //$@"D:\Studia\Mgr\Meteodata\";

        static void Main(string[] args)
        {
            string path = $@"C:\Users\Mateusz\Desktop\Meteodata\";

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("pl-PL");
            //1, 2:
            HtmlReader       htmlReader = new HtmlReader(path, 2000, 2017);
            List <MeteoData> allItems   = htmlReader.Read().OrderBy(i => i.Date).ToList();

            //new DataAnalyzer(allItems).AnalyzeAllData();
            //3:
            for (int groupSize = 1; groupSize <= 5; groupSize++)
            {
                //3.1:
                List <MeteoDataRecord> allRecords =
                    MeteoDataRecord.PrepareRecords(allItems, groupSize);
                //3.2:
                var springRecords = allRecords.Where(g => g.Season == Season.Spring).ToList();
                var summerRecords = allRecords.Where(g => g.Season == Season.Summer).ToList();
                var autumnRecords = allRecords.Where(g => g.Season == Season.Autumn).ToList();
                var winterRecords = allRecords.Where(g => g.Season == Season.Winter).ToList();
                //3.3:
                springRecords.ForEach(r => r.Labelize());
                summerRecords.ForEach(r => r.Labelize());
                autumnRecords.ForEach(r => r.Labelize());
                winterRecords.ForEach(r => r.Labelize());
                //3.4:
                MeteoDataSet springDS = new MeteoDataSet(springRecords, Season.Spring);
                MeteoDataSet summerDS = new MeteoDataSet(summerRecords, Season.Summer);
                MeteoDataSet autumnDS = new MeteoDataSet(autumnRecords, Season.Autumn);
                MeteoDataSet winterDS = new MeteoDataSet(winterRecords, Season.Winter);
                //3.5:
                List <MeteoDataSet> dataSets = new List <MeteoDataSet> {
                    springDS, summerDS, autumnDS, winterDS
                };
                Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
                foreach (var ds in dataSets)
                {
                    CsvSaver.SaveDataSet(ds, path, LabelizationMode.None);
                    CsvSaver.SaveDataSet(ds, path, LabelizationMode.Input);
                    CsvSaver.SaveDataSet(ds, path, LabelizationMode.Output);
                    CsvSaver.SaveDataSet(ds, path, LabelizationMode.Both);
                }
            }
            Console.WriteLine($"Empty records : {htmlReader.EmptyRecords}");
            Console.WriteLine("Done!");
            Console.ReadLine();
        }