/// <summary> /// Initializes a new instance of <see cref="PoissonRegression"/> /// </summary> /// <param name="env">The environment to use.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the example weight column.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public PoissonRegression(IHostEnvironment env, string featureColumn, string labelColumn, string weightColumn = null, Action <Arguments> advancedSettings = null) : base(env, featureColumn, TrainerUtils.MakeR4ScalarLabel(labelColumn), weightColumn, advancedSettings) { Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); }
/// <summary> /// Initializes a new instance of <see cref="LightGbmRegressorTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="groupIdColumn">The name for the column containing the group ID. </param> /// <param name="weightColumn">The name for the column containing the initial weight.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public LightGbmRegressorTrainer(IHostEnvironment env, string labelColumn, string featureColumn, string groupIdColumn = null, string weightColumn = null, Action <LightGbmArguments> advancedSettings = null) : base(env, LoadNameValue, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, groupIdColumn, advancedSettings) { Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); }
/// <summary> /// Initializes a new instance of <see cref="FastTreeTweedieTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="groupIdColumn">The name for the column containing the group ID. </param> /// <param name="weightColumn">The name for the column containing the initial weight.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public FastTreeTweedieTrainer(IHostEnvironment env, string labelColumn, string featureColumn, string groupIdColumn = null, string weightColumn = null, Action <Arguments> advancedSettings = null) : base(env, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, groupIdColumn, advancedSettings) { Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); Initialize(); }
/// <summary> /// Initializes a new instance of <see cref="OlsLinearRegressionTrainer"/> /// </summary> internal OlsLinearRegressionTrainer(IHostEnvironment env, Arguments args) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(args.FeatureColumn), TrainerUtils.MakeR4ScalarLabel(args.LabelColumn), TrainerUtils.MakeR4ScalarWeightColumn(args.WeightColumn, args.WeightColumn.IsExplicit)) { Host.CheckValue(args, nameof(args)); Host.CheckUserArg(args.L2Weight >= 0, nameof(args.L2Weight), "L2 regularization term cannot be negative"); _l2Weight = args.L2Weight; _perParameterSignificance = args.PerParameterSignificance; }
internal SdcaRegressionTrainer(IHostEnvironment env, Arguments args, string featureColumn, string labelColumn, string weightColumn = null) : base(env, args, TrainerUtils.MakeR4ScalarLabel(labelColumn), TrainerUtils.MakeR4ScalarWeightColumn(weightColumn)) { Host.CheckValue(labelColumn, nameof(labelColumn)); Host.CheckValue(featureColumn, nameof(featureColumn)); _loss = args.LossFunction.CreateComponent(env); Loss = _loss; }
/// <summary> /// Initializes a new instance of <see cref="LogisticRegression"/> /// </summary> /// <param name="env">The environment to use.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the example weight column.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public LogisticRegression(IHostEnvironment env, string featureColumn, string labelColumn, string weightColumn = null, Action <Arguments> advancedSettings = null) : base(env, featureColumn, TrainerUtils.MakeR4ScalarLabel(labelColumn), weightColumn, advancedSettings) { Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); _posWeight = 0; ShowTrainingStats = Args.ShowTrainingStats; }
/// <summary> /// Initializes a new instance of <see cref="FastTreeBinaryClassificationTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the column containing the initial weight.</param> /// <param name="minDocumentsInLeafs">The minimal number of documents allowed in a leaf of a regression tree, out of the subsampled data.</param> /// <param name="learningRate">The learning rate.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public RegressionGamTrainer(IHostEnvironment env, string labelColumn, string featureColumn, string weightColumn = null, int minDocumentsInLeafs = Defaults.MinDocumentsInLeafs, double learningRate = Defaults.LearningRates, Action <Arguments> advancedSettings = null) : base(env, LoadNameValue, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, minDocumentsInLeafs, learningRate, advancedSettings) { }
/// <summary> /// Initializes a new instance of <see cref="LightGbmRegressorTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the column containing the initial weight.</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> /// <param name="advancedSettings">A delegate to set more settings. /// The settings here will override the ones provided in the direct signature, /// if both are present and have different values. /// The columns names, however need to be provided directly, not through the <paramref name="advancedSettings"/>.</param> public LightGbmRegressorTrainer(IHostEnvironment env, string labelColumn, string featureColumn, string weightColumn = null, int?numLeaves = null, int?minDataPerLeaf = null, double?learningRate = null, int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, Action <LightGbmArguments> advancedSettings = null) : base(env, LoadNameValue, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, null, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings) { }
public OnlineGradientDescentTrainer(IHostEnvironment env, Arguments args) : base(args, env, UserNameValue, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn)) { LossFunction = args.LossFunction.CreateComponent(env); _outputColumns = new[] { new SchemaShape.Column(DefaultColumnNames.Score, SchemaShape.Column.VectorKind.Scalar, NumberType.R4, false, new SchemaShape(MetadataUtils.GetTrainerOutputMetadata())) }; }
public SdcaRegressionTrainer(IHostEnvironment env, Arguments args, string featureColumn, string labelColumn, string weightColumn = null) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), args, TrainerUtils.MakeR4VecFeature(featureColumn), TrainerUtils.MakeR4ScalarLabel(labelColumn), TrainerUtils.MakeR4ScalarWeightColumn(weightColumn)) { Host.CheckValue(labelColumn, nameof(labelColumn)); Host.CheckValue(featureColumn, nameof(featureColumn)); _loss = args.LossFunction.CreateComponent(env); Loss = _loss; _args = args; }
/// <summary> /// Initializes a new instance of <see cref="FastTreeBinaryClassificationTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the column containing the initial weight.</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> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public RegressionGamTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weightColumn = null, int numIterations = GamDefaults.NumIterations, double learningRate = GamDefaults.LearningRates, int maxBins = GamDefaults.MaxBins, Action <Arguments> advancedSettings = null) : base(env, LoadNameValue, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, numIterations, learningRate, maxBins, advancedSettings) { }
/// <summary> /// Initializes a new instance of <see cref="FastTreeRegressionTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the column containing the initial weight.</param> /// <param name="learningRate">The learning rate.</param> /// <param name="minDocumentsInLeafs">The minimal number of documents allowed in a leaf of a regression tree, out of the subsampled data.</param> /// <param name="numLeaves">The max number of leaves in each regression tree.</param> /// <param name="numTrees">Total number of decision trees to create in the ensemble.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public FastTreeRegressionTrainer(IHostEnvironment env, string labelColumn, string featureColumn, string weightColumn = null, int numLeaves = Defaults.NumLeaves, int numTrees = Defaults.NumTrees, int minDocumentsInLeafs = Defaults.MinDocumentsInLeafs, double learningRate = Defaults.LearningRates, Action <Arguments> advancedSettings = null) : base(env, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, null, numLeaves, numTrees, minDocumentsInLeafs, learningRate, advancedSettings) { }
/// <summary> /// Initializes a new instance of <see cref="LightGbmRankingTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="groupId">The name of the column containing the group ID. </param> /// <param name="weights">The name of the optional column containing the initial weights.</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> /// <param name="advancedSettings">A delegate to set more settings. /// The settings here will override the ones provided in the direct signature, /// if both are present and have different values. /// The columns names, however need to be provided directly, not through the <paramref name="advancedSettings"/>.</param> public LightGbmRankingTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string groupId = DefaultColumnNames.GroupId, string weights = null, int?numLeaves = null, int?minDataPerLeaf = null, double?learningRate = null, int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, Action <LightGbmArguments> advancedSettings = null) : base(env, LoadNameValue, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weights, groupId, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings) { Host.CheckNonEmpty(groupId, nameof(groupId)); }
/// <summary> /// Initializes a new instance of <see cref="PoissonRegression"/> /// </summary> /// <param name="env">The environment to use.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the example weight column.</param> /// <param name="enforceNoNegativity">Enforce non-negative weights.</param> /// <param name="l1Weight">Weight of L1 regularizer term.</param> /// <param name="l2Weight">Weight of L2 regularizer term.</param> /// <param name="memorySize">Memory size for <see cref="LogisticRegression"/>. Lower=faster, less accurate.</param> /// <param name="optimizationTolerance">Threshold for optimizer convergence.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public PoissonRegression(IHostEnvironment env, string featureColumn, string labelColumn, string weightColumn = null, float l1Weight = Arguments.Defaults.L1Weight, float l2Weight = Arguments.Defaults.L2Weight, float optimizationTolerance = Arguments.Defaults.OptTol, int memorySize = Arguments.Defaults.MemorySize, bool enforceNoNegativity = Arguments.Defaults.EnforceNonNegativity, Action <Arguments> advancedSettings = null) : base(env, featureColumn, TrainerUtils.MakeR4ScalarLabel(labelColumn), weightColumn, advancedSettings, l1Weight, l2Weight, optimizationTolerance, memorySize, enforceNoNegativity) { Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); }
/// <summary> /// Initializes a new instance of <see cref="FastTreeTweedieTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the column containing the initial weight.</param> /// <param name="learningRate">The learning rate.</param> /// <param name="minDatapointsInLeaves">The minimal number of documents allowed in a leaf of a regression tree, out of the subsampled data.</param> /// <param name="numLeaves">The max number of leaves in each regression tree.</param> /// <param name="numTrees">Total number of decision trees to create in the ensemble.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> public FastTreeTweedieTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weightColumn = null, int numLeaves = Defaults.NumLeaves, int numTrees = Defaults.NumTrees, int minDatapointsInLeaves = Defaults.MinDocumentsInLeaves, double learningRate = Defaults.LearningRates, Action <Arguments> advancedSettings = null) : base(env, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, null, numLeaves, numTrees, minDatapointsInLeaves, learningRate, advancedSettings) { Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); Initialize(); }
/// <summary> /// Initializes a new instance of <see cref="SdcaRegressionTrainer"/> /// </summary> /// <param name="env">The environment to use.</param> /// <param name="featureColumn">The features, or independent variables.</param> /// <param name="labelColumn">The label, or dependent variable.</param> /// <param name="loss">The custom loss.</param> /// <param name="weightColumn">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="advancedSettings">A delegate to set more settings.</param> public SdcaRegressionTrainer(IHostEnvironment env, string featureColumn, string labelColumn, string weightColumn = null, ISupportSdcaRegressionLoss loss = null, float?l2Const = null, float?l1Threshold = null, int?maxIterations = null, Action <Arguments> advancedSettings = null) : base(env, featureColumn, TrainerUtils.MakeR4ScalarLabel(labelColumn), TrainerUtils.MakeR4ScalarWeightColumn(weightColumn), advancedSettings, l2Const, l1Threshold, maxIterations) { Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); _loss = loss ?? Args.LossFunction.CreateComponent(env); Loss = _loss; }
/// <summary> /// Initializes a new instance of <see cref="FastTreeRegressionTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the column containing the initial weight.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param> /// <param name="learningRate">The learning rate.</param> /// <param name="minDocumentsInLeafs">The minimal number of documents allowed in a leaf of a regression tree, out of the subsampled data.</param> /// <param name="numLeaves">The max number of leaves in each regression tree.</param> /// <param name="numTrees">Total number of decision trees to create in the ensemble.</param> public FastTreeRegressionTrainer(IHostEnvironment env, string labelColumn, string featureColumn, string weightColumn = null, int numLeaves = Defaults.NumLeaves, int numTrees = Defaults.NumTrees, int minDocumentsInLeafs = Defaults.MinDocumentsInLeafs, double learningRate = Defaults.LearningRates, Action <Arguments> advancedSettings = null) : base(env, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, null, advancedSettings) { Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); if (advancedSettings != null) { CheckArgsAndAdvancedSettingMismatch(numLeaves, numTrees, minDocumentsInLeafs, learningRate, new Arguments(), Args); } }
/// <summary> /// Trains a new <see cref="RegressionPredictionTransformer{LinearRegressionPredictor}"/>. /// </summary> /// <param name="env">The pricate instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">Name of the label column.</param> /// <param name="featureColumn">Name of the feature column.</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> /// <param name="weightsColumn">The name of the weights column.</param> /// <param name="lossFunction">The custom loss functions. Defaults to <see cref="SquaredLoss"/> if not provided.</param> public OnlineGradientDescentTrainer(IHostEnvironment env, string labelColumn, string featureColumn, float learningRate = Arguments.OgdDefaultArgs.LearningRate, bool decreaseLearningRate = Arguments.OgdDefaultArgs.DecreaseLearningRate, float l2RegularizerWeight = Arguments.OgdDefaultArgs.L2RegularizerWeight, int numIterations = Arguments.OgdDefaultArgs.NumIterations, string weightsColumn = null, IRegressionLoss lossFunction = null) : base(new Arguments { LearningRate = learningRate, DecreaseLearningRate = decreaseLearningRate, L2RegularizerWeight = l2RegularizerWeight, NumIterations = numIterations, LabelColumn = labelColumn, FeatureColumn = featureColumn, InitialWeights = weightsColumn }, env, UserNameValue, TrainerUtils.MakeR4ScalarLabel(labelColumn)) { LossFunction = lossFunction ?? new SquaredLoss(); }
/// <summary> /// Initializes a new instance of <see cref="LightGbmRegressorTrainer"/> /// </summary> /// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> /// <param name="weightColumn">The name for the column containing the initial weight.</param> /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</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> public LightGbmRegressorTrainer(IHostEnvironment env, string labelColumn, string featureColumn, string weightColumn = null, int?numLeaves = null, int?minDataPerLeaf = null, double?learningRate = null, int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, Action <LightGbmArguments> advancedSettings = null) : base(env, LoadNameValue, TrainerUtils.MakeR4ScalarLabel(labelColumn), featureColumn, weightColumn, null, advancedSettings) { Host.CheckNonEmpty(labelColumn, nameof(labelColumn)); Host.CheckNonEmpty(featureColumn, nameof(featureColumn)); if (advancedSettings != null) { CheckArgsAndAdvancedSettingMismatch(numLeaves, minDataPerLeaf, learningRate, numBoostRound, new LightGbmArguments(), Args); } // override with the directly provided values Args.NumBoostRound = numBoostRound; Args.NumLeaves = numLeaves ?? Args.NumLeaves; Args.LearningRate = learningRate ?? Args.LearningRate; Args.MinDataPerLeaf = minDataPerLeaf ?? Args.MinDataPerLeaf; }
internal OnlineGradientDescentTrainer(IHostEnvironment env, Arguments args) : base(args, env, UserNameValue, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn)) { LossFunction = args.LossFunction.CreateComponent(env); }
/// <summary> /// Initializes a new instance of <see cref="FastTreeTweedieTrainer"/> by using the legacy <see cref="Arguments"/> class. /// </summary> internal FastTreeTweedieTrainer(IHostEnvironment env, Arguments args) : base(env, args, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn)) { Initialize(); }
internal RegressionGamTrainer(IHostEnvironment env, Arguments args) : base(env, args, LoadNameValue, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn)) { }
/// <summary> /// Initializes a new instance of <see cref="LogisticRegression"/> /// </summary> internal LogisticRegression(IHostEnvironment env, Arguments args) : base(env, args, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn)) { _posWeight = 0; ShowTrainingStats = Args.ShowTrainingStats; }
/// <summary> /// Initializes a new instance of <see cref="FastTreeRegressionTrainer"/> by using the legacy <see cref="Arguments"/> class. /// </summary> internal FastTreeRegressionTrainer(IHostEnvironment env, Arguments args) : base(env, args, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn)) { }
internal LightGbmRegressorTrainer(IHostEnvironment env, LightGbmArguments args) : base(env, LoadNameValue, args, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn)) { }
/// <summary> /// Initializes a new instance of <see cref="FastForestRegression"/> by using the legacy <see cref="Arguments"/> class. /// </summary> public FastForestRegression(IHostEnvironment env, Arguments args) : base(env, args, TrainerUtils.MakeR4ScalarLabel(args.LabelColumn), true) { }