Example #1
0
        static void Main(string[] args)
        {
            string assetsPath  = GetAbsolutePath(@"../../../assets");
            string trainOutput = GetAbsolutePath(@"../../../../CreditCardFraudDetection.Trainer\assets\output");

            CopyModelAndDatasetFromTrainingProject(trainOutput, assetsPath);

            var inputDatasetForPredictions = Path.Combine(assetsPath, "input", "testData.csv");
            var modelFilePath = Path.Combine(assetsPath, "input", "fastTree.zip");

            // Create model predictor to perform a few predictions
            var modelPredictor = new Predictor(modelFilePath, inputDatasetForPredictions);

            modelPredictor.RunMultiplePredictions(numberOfPredictions: 5);

            Console.WriteLine("=============== Press any key ===============");
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            string assetsPath  = GetAbsolutePath(@"../../../assets");
            string trainOutput = GetAbsolutePath(@"../../../../CreditCardFraudDetection.Trainer/assets/output");

            var inputDatasetForPredictions = Path.Combine(assetsPath, "input", "testData.csv");
            var modelFilePath = Path.Combine(assetsPath, "input", "randomizedPca.zip");

            //Always copy the trained model from the trainer project just in case there's a new version trained.
            CopyModelAndDatasetFromTrainingProject(trainOutput, assetsPath);

            // Create model predictor to perform a few predictions
            var modelPredictor = new Predictor(modelFilePath, inputDatasetForPredictions);

            modelPredictor.RunMultiplePredictions(numberOfPredictions: 5);

            Console.WriteLine("=============== Press any key ===============");
            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            var assetsPath  = ConsoleHelpers.GetAssetsPath(@"..\..\..\assets");
            var trainOutput = ConsoleHelpers.GetAssetsPath(@"..\..\..\..\CreditCardFraudDetection.Trainer\assets\output");


            if (!File.Exists(Path.Combine(trainOutput, "testData.csv")) ||
                !File.Exists(Path.Combine(trainOutput, "fastTree.zip")))
            {
                ConsoleHelpers.ConsoleWriteWarning("YOU SHOULD RUN TRAIN PROJECT FIRST");
                ConsoleHelpers.ConsolePressAnyKey();
                return;
            }

            // copy files from train output
            Directory.CreateDirectory(assetsPath);
            foreach (var file in Directory.GetFiles(trainOutput))
            {
                var fileDestination = Path.Combine(Path.Combine(assetsPath, "input"), Path.GetFileName(file));
                if (File.Exists(fileDestination))
                {
                    ConsoleHelpers.DeleteAssets(fileDestination);
                }

                File.Copy(file, Path.Combine(Path.Combine(assetsPath, "input"), Path.GetFileName(file)));
            }

            var dataSetFile = Path.Combine(assetsPath, "input", "testData.csv");
            var modelFile   = Path.Combine(assetsPath, "input", "fastTree.zip");


            var modelEvaluator = new Predictor(modelFile, dataSetFile);

            int numberOfTransactions = 5;

            modelEvaluator.RunMultiplePredictions(numberOfTransactions);

            ConsoleHelpers.ConsolePressAnyKey();
        }