コード例 #1
0
        static DynamicKMeans TrainModel(List <Song> songs, int clustersCount)
        {
            DynamicKMeans kMeans = new DynamicKMeans(songs, clustersCount);

            kMeans.Clusterize();
            // ConsoleHelper.ShowClusters(kMeans);

            return(kMeans);
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            AppConfig appConfig = FileSystemHelper.GetAppConfig();
            DateTime  runDate   = GetRunDate();

            List <Song> songs = GetPreparedTrainingData();

            int experimentIndex = 0;

            foreach (ExperimentConfig config in appConfig.ExperimentConfigs)
            {
                for (int i = 0; i < config.ModelsCount; i++)
                {
                    DynamicKMeans trainedKMeans = TrainModel(songs, config.ClustersCount);
                    FileSystemHelper.SaveKMeansModel(trainedKMeans.Model, runDate, experimentIndex);

                    experimentIndex += 1;
                }
            }

            List <StaticKMeans> models = ReadAllModels(songs);

            List <ModelAnalyzer> analyzers = models.Select(model =>
            {
                ModelAnalyzer analyzer = new ModelAnalyzer(model);
                analyzer.Analyze();

                return(analyzer);
            }).ToList();

            AnalysisDrawer drawer = new AnalysisDrawer(analyzers);

            drawer.CreatePlots();
            FileSystemHelper.SaveAnalysis(drawer, runDate);

            List <Song> analyzingSongs = GetAnalyzingSongs();

            FileSystemHelper.ClearPredictions();

            for (int i = 0; i < models.Count; i++)
            {
                StaticKMeans      model       = models[i];
                List <Prediction> predictions = MakePredictions(model, analyzingSongs);
                FileSystemHelper.SavePredictions(predictions, runDate, i);
            }
        }