Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            cntkModelToGraphviz();

            return;

            //Iris flower recognition
            //Famous multi class classification datset: https://archive.ics.uci.edu/ml/datasets/iris
            string root = "C:\\sc\\github\\anndotnet\\src\\tool\\";

            var mlConfigFile2 = $"{root}\\anndotnet.tool\\model_mlconfigs\\iris.mlconfig";

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine($"****Iris flower recognition****");
            Console.WriteLine(Environment.NewLine);
            var token2 = new CancellationToken();
            var result = MachineLearning.Run(mlConfigFile2, DeviceDescriptor.UseDefaultDevice(), token2, trainingProgress, null);

            ////evaluate model and export the result of testing
            MachineLearning.EvaluateModel(mlConfigFile2, result.BestModelFile, DeviceDescriptor.UseDefaultDevice());

            //******run all configurations in the solution******

            //for (int i = 0; i < 10; i++)
            //    runAllml_configurations(strLocation1)

            //*****end of program*****
            Console.WriteLine("Press any key to continue!");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
 private static void runConvNetExample()
 {
     //cat&dag dataset location C:\sc\Datasets\cat-dog\train
     //train mlconfig
     var mlConfigFile1 = $"model_mlconfigs\\convNet.mlconfig";
     var result        = MachineLearning.Train(mlConfigFile1, trainingProgress, new CancellationToken(), null);
 }
Ejemplo n.º 3
0
        static void TrainExamples()
        {
            for (int i = 0; i < 10; i++)
            {
                //Iris flower recognition
                //Famous multi class classification datset: https://archive.ics.uci.edu/ml/datasets/iris
                var mlConfigFile2 = "./model_mlconfigs/iris.mlconfig";
                Console.WriteLine(Environment.NewLine);
                Console.Title = $"****Iris flower recognition****";
                Console.WriteLine($"****Iris flower recognition****");
                Console.WriteLine(Environment.NewLine);
                var token2 = new CancellationToken();
                var result = MachineLearning.Train(mlConfigFile2, trainingProgress, token2, null);


                //Bezier Curve Machine Learning Demonstration
                //dataset taken form Code Project Article:
                //https://www.codeproject.com/Articles/1256883/Bezier-Curve-Machine-Learning-Demonstration
                var mlConfigFile = "./model_mlconfigs/BCML.mlconfig";
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine($"****Bezier Curve Machine Learning Demonstration****");
                Console.WriteLine(Environment.NewLine);
                var token = new CancellationToken();
                MachineLearning.Train(mlConfigFile, trainingProgress, token, null);

                //1. daily sales
                //modified dataset from preidct future sales
                var ds_mlConfigFile = "./model_mlconfigs/daily_sales.mlconfig";
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine($"****Predict Daily Sales for 10 items****");
                Console.WriteLine(Environment.NewLine);
                MachineLearning.Train(ds_mlConfigFile, trainingProgress, new CancellationToken(), null);


                //1. solar production
                //CNTK Tutorial 106B_ https://cntk.ai/pythondocs/CNTK_106B_LSTM_Timeseries_with_IOT_Data.html
                var mlConfigFile11 = "C:\\Users\\bhrnjica\\OneDrive - BHRNJICA\\AI Projects\\ann-custom-models" +
                                     "\\solar_production.mlconfig";
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine($"****Predict Solar production****");
                Console.WriteLine(Environment.NewLine);
                var token11 = new CancellationToken();
                MachineLearning.Train(mlConfigFile11, trainingProgress, token11, null);


                //2. Predict future sales,-  Multiple Input variables
                //Kaggle competition dataset
                var mlConfigFile1 = "C:\\Users\\bhrnjica\\OneDrive - BHRNJICA\\AI Projects\\ann-custom-models" +
                                    "\\predict_future_sales.mlconfig";
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine($"****Predict Future Sales****");
                Console.WriteLine(Environment.NewLine);
                var token1 = new CancellationToken();
                //MachineLearning.Train(mlConfigFile1, trainingProgress, token1, CustomNNModels.CustomModelCallEntryPoint);
            }
        }
Ejemplo n.º 4
0
        private static void runExample(string title, string mlConfigPath, CreateCustomModel model = null)
        {
            var mlConfigFile2 = mlConfigPath;

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine($"****{title}****");
            Console.WriteLine(Environment.NewLine);
            var token2 = new CancellationToken();

            MachineLearning.Train(mlConfigFile2, trainingProgress, token2, model);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            //graphConvNetExample();

            //runConvNetExample();
            //cntkModelToGraphviz();
            //Console.ReadKey();
            //return;

            var   rnd         = new Random(1);
            Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));

            //var root = "C:\\sc\\github\\anndotnet\\src\\tool";
            //Iris flower recognition
            //Famous multi class classification datset: https://archive.ics.uci.edu/ml/datasets/iris

            var mlConfigFile3 = $"model_mlconfigs\\iris.mlconfig";

            //run example
            // var token2 = new CancellationToken();

            //train mlconfig
            var result = MachineLearning.Train(mlConfigFile3, trainingProgress, new CancellationToken(), null);

            //once the mode is trained you can write performance analysis of the model
            MachineLearning.PrintPerformance(mlConfigFile3);

            //SHow training history
            showTrainingHistory(mlConfigFile3);

            //evaluate model and export the result of testing
            //MLExport.ExportToCSV(mlConfigFile2, DeviceDescriptor.UseDefaultDevice(),"./model_mlconfigs/iris_result.csv" ).Wait();



            //******run all configurations in the solution******

            //for (int i = 0; i < 10; i++)
            //    runAllml_configurations(strLocation1);


            //*****end of program*****
            Console.WriteLine("Press any key to continue!");
            Console.ReadKey();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            string root = "C:\\sc\\github\\anndotnet\\src\\tool\\";

            //transformDailyLevelVeanaLake();
            //return;

            //regression
            var mlConfigFile1 = $"{root}anndotnet.wnd\\Resources\\Concrete\\ConcreteSlumpProject\\FFNModel.mlconfig";

            //binary classification
            var mlConfigFile2 = $"{root}anndotnet.wnd\\Resources\\Titanic\\TitanicProject\\DNNModel.mlconfig";

            //Multi-class classification
            //Famous multi class classification datset: https://archive.ics.uci.edu/ml/datasets/iris
            var mlConfigFile3 = "./model_mlconfigs/iris.mlconfig";

            //run example
            var token2 = new CancellationToken();

            //train mlconfig
            var result = MachineLearning.Train(mlConfigFile3, trainingProgress, token2, null);

            //once the mode is trained you can write performance analysis of the model
            MachineLearning.PrintPerformance(mlConfigFile1);

            //evaluate model and export the result of testing
            MLExport.ExportToCSV(mlConfigFile2, DeviceDescriptor.UseDefaultDevice(), "./model_mlconfigs/iris_result.csv").Wait();

            //******run all configurations in the solution******
            //string strLocation1 = "C:\\sc\\github\\anndotnet\\src\\tool\\";
            //for (int i = 0; i < 10; i++)
            //    runAllml_configurations(strLocation1);


            //*****end of program*****
            Console.WriteLine("Press any key to continue!");
            Console.ReadKey();
        }
Ejemplo n.º 7
0
        private static void showTrainingHistory(string mlConfigFile3)
        {
            var history = MachineLearning.ShowTrainingHistory(mlConfigFile3);
            var data    = history.First().Value;
            var header  = history.First().Key;
            var x       = header.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            var model = DataProcessing.Core.ChartComponent.LinePlot("Model Evaluation", "Training Data",
                                                                    data.Select(d => (double)d.Item1).ToArray(),
                                                                    data.Select(d => (double)d.Item4).ToArray(),
                                                                    Color.Blue, MarkerType.Circle,
                                                                    "Iterations", x.Last());

            var ss = DataProcessing.Core.ChartComponent.LineSeries("Validation Data",
                                                                   data.Select(d => (double)d.Item1).ToArray(),
                                                                   data.Select(d => (double)d.Item5).ToArray(),
                                                                   Color.Orange, MarkerType.Circle);

            model.Series.Add(ss);

            model.LegendPosition = LegendPosition.LeftTop;

            showPlot(model).Wait();
        }