Esempio n. 1
0
        public ITransformer TrainModel(TrainingAlgorithm algorithm, DataControl.TrainingOptions options)
        {
            switch (algorithm)
            {
            case TrainingAlgorithm.LOGISTIC_REGRESSION:
                return(LogisticRegression(options));

            case TrainingAlgorithm.NAIVE_BAYES:
                return(NaiveBayes(options));

            case TrainingAlgorithm.BINARY_STOCHASTIC_DUAL_COORDINATE_ASCENT:
                return(BinaryStochasticDualCoordinateAscent(options));

            case TrainingAlgorithm.FAST_TREE:
                return(FastTree(options));

            case TrainingAlgorithm.STOCHASTIC_DUAL_COORDINATE_ASCENT:
                return(StochasticDualCoordinateAscent(options));

            case TrainingAlgorithm.STOCHASTIC_GRADIENT_DESCENT:
                return(StochasticGradientDescent(options));

            default:
                return(null);
            }
        }
Esempio n. 2
0
        private ITransformer LogisticRegression(DataControl.TrainingOptions options)
        {
            var pipeline = context.Transforms.Conversion
                           .ConvertType(options.LabelColumn, options.LabelColumn, DataKind.R4)
                           .Append(context.MulticlassClassification.Trainers.LogisticRegression(
                                       labelColumn: options.LabelColumn,
                                       featureColumn: options.FeatureColumn));

            Console.WriteLine("============== Create and Train Logistic Regression Model ==============");
            var model = pipeline.Fit(trainData);

            Console.WriteLine("================= Finished Training ================");
            Console.WriteLine();
            return(model);
        }
Esempio n. 3
0
        private ITransformer FastTree(DataControl.TrainingOptions options)
        {
            var pipeline = context.BinaryClassification.Trainers.FastTree(
                labelColumn: options.LabelColumn,
                featureColumn: options.FeatureColumn,
                learningRate: options.LearningRate
                );

            Console.WriteLine("============== Create and Train Averaged Perceptron Model ==============");
            var model = pipeline.Fit(trainData);

            Console.WriteLine("================= Finished Training ================");
            Console.WriteLine();
            return(model);
        }
Esempio n. 4
0
        private ITransformer BinaryStochasticDualCoordinateAscent(DataControl.TrainingOptions options)
        {
            var pipeline = context.BinaryClassification.Trainers.StochasticDualCoordinateAscent(
                labelColumn: options.LabelColumn,
                featureColumn: options.FeatureColumn,
                maxIterations: options.MaxIterations
                );

            Console.WriteLine("============== Create and Train Averaged Perceptron Model ==============");
            var model = pipeline.Fit(trainData);

            Console.WriteLine("================= Finished Training ================");
            Console.WriteLine();
            return(model);
        }
Esempio n. 5
0
        private ITransformer StochasticDualCoordinateAscent(DataControl.TrainingOptions options)
        {
            var pipeline = context.Transforms.Conversion
                           .ConvertType(options.LabelColumn, options.LabelColumn, DataKind.R4)
                           .Append(context.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(
                                       labelColumn: options.LabelColumn,
                                       featureColumn: options.FeatureColumn,
                                       maxIterations: options.MaxIterations));

            Console.WriteLine("========== Training Stochastic Dual Coordinate Ascent Model =========");
            var model = pipeline.Fit(trainData);

            Console.WriteLine("================= Finished Training ================");
            Console.WriteLine();
            return(model);
        }