/// <summary> /// Predict a target using a decision tree regression model trained with the <see cref="LightGbmRegressorTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="options">Advanced options to the algorithm.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[ScoreTensorFlowModel](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/LightGBMRegressionWithOptions.cs)] /// ]]> /// </format> /// </example> public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return new LightGbmRegressorTrainer(env, options); }
/// <summary> /// Predict a target using generalized additive models trained with the <see cref="RegressionGamTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="options">Algorithm advanced settings.</param> public static RegressionGamTrainer GeneralizedAdditiveModels(this RegressionCatalog.RegressionTrainers catalog, RegressionGamTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new RegressionGamTrainer(env, options)); }
/// <summary> /// Create <see cref="GamRegressionTrainer"/> using advanced options, which predicts a target using generalized additive models (GAM). /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="options">Trainer options.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[Gam](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/GamWithOptions.cs)] /// ]]> /// </format> /// </example> public static GamRegressionTrainer Gam(this RegressionCatalog.RegressionTrainers catalog, GamRegressionTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new GamRegressionTrainer(env, options)); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Trainers.PoissonRegression"/> trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="options">Advanced arguments to the algorithm.</param> public static PoissonRegression PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, PoissonRegression.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); return(new PoissonRegression(env, options)); }
/// <summary> /// Predict a target using a linear regression model trained with the SDCA trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="options">Advanced arguments to the algorithm.</param> public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this RegressionCatalog.RegressionTrainers catalog, SdcaRegressionTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); return(new SdcaRegressionTrainer(env, options)); }
/// <summary> /// Predict a target using a decision tree regression model trained with the <see cref="FastTreeRegressionTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="options">Algorithm advanced settings.</param> public static FastTreeRegressionTrainer FastTree(this RegressionCatalog.RegressionTrainers catalog, FastTreeRegressionTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); return(new FastTreeRegressionTrainer(env, options)); }
/// <summary> /// Create <see cref="OlsTrainer"/> with advanced options, which predicts a target using a linear regression model. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="options">Algorithm advanced options. See <see cref="OlsTrainer.Options"/>.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[OrdinaryLeastSquares](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquaresWithOptions.cs)] /// ]]> /// </format> /// </example> public static OlsTrainer Ols( this RegressionCatalog.RegressionTrainers catalog, OlsTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); return new OlsTrainer(env, options); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="OnlineGradientDescentTrainer"/> trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="options">Advanced arguments to the algorithm.</param> public static OnlineGradientDescentTrainer OnlineGradientDescent(this RegressionCatalog.RegressionTrainers catalog, OnlineGradientDescentTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); return(new OnlineGradientDescentTrainer(env, options)); }
/// <summary> /// Predict a target using a decision tree regression model trained with the <see cref="FastForestRegression"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumn">The labelColumn column.</param> /// <param name="featureColumn">The featureColumn column.</param> /// <param name="weights">The optional weights column.</param> /// <param name="numTrees">Total number of decision trees to create in the ensemble.</param> /// <param name="numLeaves">The maximum number of leaves per decision tree.</param> /// <param name="minDatapointsInLeaves">The minimal number of datapoints allowed in a leaf of the tree, out of the subsampled data.</param> public static FastForestRegression FastForest(this RegressionCatalog.RegressionTrainers catalog, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, int numLeaves = Defaults.NumLeaves, int numTrees = Defaults.NumTrees, int minDatapointsInLeaves = Defaults.MinDocumentsInLeaves) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new FastForestRegression(env, labelColumn, featureColumn, weights, numLeaves, numTrees, minDatapointsInLeaves)); }
/// <summary> /// Predict a target using a decision tree regression model trained with the <see cref="LightGbmRegressorTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumn">The labelColumn column.</param> /// <param name="featureColumn">The features column.</param> /// <param name="weights">The weights column.</param> /// <param name="numLeaves">The number of leaves to use.</param> /// <param name="numBoostRound">Number of iterations.</param> /// <param name="minDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> /// <param name="learningRate">The learning rate.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[ScoreTensorFlowModel](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/LightGBMRegression.cs)] /// ]]> /// </format> /// </example> public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, int? numLeaves = null, int? minDataPerLeaf = null, double? learningRate = null, int numBoostRound = Options.Defaults.NumBoostRound) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return new LightGbmRegressorTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound); }
/// <summary> /// Predict a target using generalized additive models trained with the <see cref="RegressionGamTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumn">The labelColumn column.</param> /// <param name="featureColumn">The featureColumn column.</param> /// <param name="weights">The optional weights column.</param> /// <param name="numIterations">The number of iterations to use in learning the features.</param> /// <param name="learningRate">The learning rate. GAMs work best with a small learning rate.</param> /// <param name="maxBins">The maximum number of bins to use to approximate features.</param> public static RegressionGamTrainer GeneralizedAdditiveModels(this RegressionCatalog.RegressionTrainers catalog, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, int numIterations = GamDefaults.NumIterations, double learningRate = GamDefaults.LearningRates, int maxBins = GamDefaults.MaxBins) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new RegressionGamTrainer(env, labelColumn, featureColumn, weights, numIterations, learningRate, maxBins)); }
/// <summary> /// Predict a target using a decision tree regression model trained with the <see cref="FastForestRegression"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumnName">The name of the label column.</param> /// <param name="featureColumnName">The name of the feature column.</param> /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param> /// <param name="numberOfLeaves">The maximum number of leaves per decision tree.</param> /// <param name="numberOfTrees">Total number of decision trees to create in the ensemble.</param> /// <param name="minDatapointsInLeaves">The minimal number of datapoints allowed in a leaf of the tree, out of the subsampled data.</param> public static FastForestRegression FastForest(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, int numberOfLeaves = Defaults.NumberOfLeaves, int numberOfTrees = Defaults.NumberOfTrees, int minDatapointsInLeaves = Defaults.MinimumExampleCountPerLeaf) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new FastForestRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, numberOfTrees, minDatapointsInLeaves)); }
/// <summary> /// Predict a target using generalized additive models trained with the <see cref="RegressionGamTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumnName">The name of the label column.</param> /// <param name="featureColumnName">The name of the feature column.</param> /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param> /// <param name="numberOfIterations">The number of iterations to use in learning the features.</param> /// <param name="maximumBinCountPerFeature">The maximum number of bins to use to approximate features.</param> /// <param name="learningRate">The learning rate. GAMs work best with a small learning rate.</param> public static RegressionGamTrainer GeneralizedAdditiveModels(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, int numberOfIterations = GamDefaults.NumberOfIterations, int maximumBinCountPerFeature = GamDefaults.MaximumBinCountPerFeature, double learningRate = GamDefaults.LearningRate) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new RegressionGamTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfIterations, learningRate, maximumBinCountPerFeature)); }
/// <summary> /// Predict a target using a decision tree regression model trained with the <see cref="FastTreeRegressionTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumnName">The name of the label column.</param> /// <param name="featureColumnName">The name of the feature column.</param> /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param> /// <param name="numTrees">Total number of decision trees to create in the ensemble.</param> /// <param name="numLeaves">The maximum number of leaves per decision tree.</param> /// <param name="minDatapointsInLeaves">The minimal number of datapoints allowed in a leaf of a regression tree, out of the subsampled data.</param> /// <param name="learningRate">The learning rate.</param> public static FastTreeRegressionTrainer FastTree(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, int numLeaves = Defaults.NumLeaves, int numTrees = Defaults.NumTrees, int minDatapointsInLeaves = Defaults.MinDocumentsInLeaves, double learningRate = Defaults.LearningRates) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new FastTreeRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numLeaves, numTrees, minDatapointsInLeaves, learningRate)); }
/// <summary> /// Predict a target using a decision tree regression model trained with the <see cref="LightGbmRegressorTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumnName">The name of the label column.</param> /// <param name="featureColumnName">The name of the feature column.</param> /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param> /// <param name="numberOfLeaves">The number of leaves to use.</param> /// <param name="minimumExampleCountPerLeaf">The minimal number of data points allowed in a leaf of the tree, out of the subsampled data.</param> /// <param name="learningRate">The learning rate.</param> /// <param name="numberOfIterations">The number of iterations to use.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[ScoreTensorFlowModel](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/LightGBMRegression.cs)] /// ]]> /// </format> /// </example> public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, int?numberOfLeaves = null, int?minimumExampleCountPerLeaf = null, double?learningRate = null, int numberOfIterations = Options.Defaults.NumberOfIterations) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new LightGbmRegressorTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations)); }
/// <summary> /// Create <see cref="FastTreeTweedieTrainer"/>, which predicts a target using a decision tree regression model. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumnName">The name of the label column. The column data must be <see cref="System.Single"/>.</param> /// <param name="featureColumnName">The name of the feature column. The column data must be a known-sized vector of <see cref="System.Single"/>.</param> /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param> /// <param name="numberOfTrees">Total number of decision trees to create in the ensemble.</param> /// <param name="numberOfLeaves">The maximum number of leaves per decision tree.</param> /// <param name="minimumExampleCountPerLeaf">The minimal number of data points required to form a new tree leaf.</param> /// <param name="learningRate">The learning rate.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[FastTreeTweedie](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/FastTreeTweedie.cs)] /// ]]> /// </format> /// </example> public static FastTreeTweedieTrainer FastTreeTweedie(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, int numberOfLeaves = Defaults.NumberOfLeaves, int numberOfTrees = Defaults.NumberOfTrees, int minimumExampleCountPerLeaf = Defaults.MinimumExampleCountPerLeaf, double learningRate = Defaults.LearningRate) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new FastTreeTweedieTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, numberOfTrees, minimumExampleCountPerLeaf, learningRate)); }
/// <summary> /// Predict a target using a linear regression model trained with the SDCA trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="labelColumnName">The label column, or dependent variable.</param> /// <param name="featureColumnName">The features, or independent variables.</param> /// <param name="weightColumnName">The optional example weights.</param> /// <param name="l2Const">The L2 regularization hyperparameter.</param> /// <param name="l1Threshold">The L1 regularization hyperparameter. Higher values will tend to lead to more sparse model.</param> /// <param name="maxIterations">The maximum number of passes to perform over the data.</param> /// <param name="loss">The custom loss, if unspecified will be <see cref="SquaredLoss"/>.</param> public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string weightColumnName = null, ISupportSdcaRegressionLoss loss = null, float?l2Const = null, float?l1Threshold = null, int?maxIterations = null) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new SdcaRegressionTrainer(env, labelColumnName, featureColumnName, weightColumnName, loss, l2Const, l1Threshold, maxIterations)); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Trainers.PoissonRegression"/> trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="labelColumn">The labelColumn, or dependent variable.</param> /// <param name="featureColumn">The features, or independent variables.</param> /// <param name="weights">The optional example weights.</param> /// <param name="l1Weight">Weight of L1 regularization term.</param> /// <param name="l2Weight">Weight of L2 regularization term.</param> /// <param name="optimizationTolerance">Threshold for optimizer convergence.</param> /// <param name="memorySize">Memory size for <see cref="Microsoft.ML.Trainers.PoissonRegression"/>. Low=faster, less accurate.</param> /// <param name="enforceNoNegativity">Enforce non-negative weights.</param> public static PoissonRegression PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, float l1Weight = LROptions.Defaults.L1Weight, float l2Weight = LROptions.Defaults.L2Weight, float optimizationTolerance = LROptions.Defaults.OptTol, int memorySize = LROptions.Defaults.MemorySize, bool enforceNoNegativity = LROptions.Defaults.EnforceNonNegativity) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new PoissonRegression(env, labelColumn, featureColumn, weights, l1Weight, l2Weight, optimizationTolerance, memorySize, enforceNoNegativity)); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="OnlineGradientDescentTrainer"/> trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="labelColumn">The name of the label, or dependent variable.</param> /// <param name="featureColumn">The features, or independent variables.</param> /// <param name="lossFunction">The custom loss. Defaults to <see cref="SquaredLoss"/> if not provided.</param> /// <param name="learningRate">The learning Rate.</param> /// <param name="decreaseLearningRate">Decrease learning rate as iterations progress.</param> /// <param name="l2RegularizerWeight">L2 regularization weight.</param> /// <param name="numIterations">Number of training iterations through the data.</param> public static OnlineGradientDescentTrainer OnlineGradientDescent(this RegressionCatalog.RegressionTrainers catalog, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, IRegressionLoss lossFunction = null, float learningRate = OnlineGradientDescentTrainer.Options.OgdDefaultArgs.LearningRate, bool decreaseLearningRate = OnlineGradientDescentTrainer.Options.OgdDefaultArgs.DecreaseLearningRate, float l2RegularizerWeight = AveragedLinearArguments.AveragedDefaultArgs.L2RegularizerWeight, int numIterations = OnlineLinearArguments.OnlineDefaultArgs.NumIterations) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); return(new OnlineGradientDescentTrainer(env, labelColumn, featureColumn, learningRate, decreaseLearningRate, l2RegularizerWeight, numIterations, lossFunction)); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="OlsTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumnName">The name of the label column.</param> /// <param name="featureColumnName">The name of the feature column.</param> /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[OrdinaryLeastSquares](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquares.cs)] /// ]]> /// </format> /// </example> public static OlsTrainer Ols(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); var options = new OlsTrainer.Options { LabelColumnName = labelColumnName, FeatureColumnName = featureColumnName, ExampleWeightColumnName = exampleWeightColumnName }; return(new OlsTrainer(env, options)); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="OlsLinearRegressionTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="labelColumn">The labelColumn column.</param> /// <param name="featureColumn">The features column.</param> /// <param name="weights">The weights column.</param> public static OlsLinearRegressionTrainer OrdinaryLeastSquares(this RegressionCatalog.RegressionTrainers catalog, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); var options = new OlsLinearRegressionTrainer.Options { LabelColumn = labelColumn, FeatureColumn = featureColumn, WeightColumn = weights != null ? Optional <string> .Explicit(weights) : Optional <string> .Implicit(DefaultColumnNames.Weight) }; return(new OlsLinearRegressionTrainer(env, options)); }