/// <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="label">The label, or dependent variable.</param> /// <param name="features">The features, or independent variables.</param> /// <param name="weights">The optional example weights.</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="l2Regularization">L2 regularization weight.</param> /// <param name="numIterations">Number of training iterations through the data.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained, as well as the calibrator on top of that model. Note that this action cannot change the /// result in any way; it is only a way for the caller to be informed about what was learnt.</param> /// <returns>The set of output columns including in order the predicted binary classification score (which will range /// from negative to positive infinity), and the predicted label.</returns> /// <seealso cref="OnlineGradientDescentTrainer"/>. /// <returns>The predicted output.</returns> public static Scalar <float> OnlineGradientDescent(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights = null, IRegressionLoss lossFunction = null, float learningRate = OnlineGradientDescentTrainer.Options.OgdDefaultArgs.LearningRate, bool decreaseLearningRate = OnlineGradientDescentTrainer.Options.OgdDefaultArgs.DecreaseLearningRate, float l2Regularization = OnlineGradientDescentTrainer.Options.OgdDefaultArgs.L2Regularization, int numIterations = OnlineLinearOptions.OnlineDefault.NumberOfIterations, Action <LinearRegressionModelParameters> onFit = null) { OnlineLinearStaticUtils.CheckUserParams(label, features, weights, learningRate, l2Regularization, numIterations, onFit); Contracts.CheckValueOrNull(lossFunction); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { var trainer = new OnlineGradientDescentTrainer(env, labelName, featuresName, learningRate, decreaseLearningRate, l2Regularization, numIterations, lossFunction); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <summary> /// FastTree <see cref="RegressionCatalog"/> extension method. /// Predicts 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="label">The label column.</param> /// <param name="features">The features column.</param> /// <param name="weights">The optional weights column.</param> /// <param name="options">Algorithm advanced settings.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained. Note that this action cannot change the result in any way; /// it is only a way for the caller to be informed about what was learnt.</param> /// <returns>The Score output column indicating the predicted value.</returns> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[FastTree](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Static/FastTreeRegression.cs)] /// ]]></format> /// </example> public static Scalar <float> FastTree(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights, FastTreeRegressionTrainer.Options options, Action <FastTreeRegressionModelParameters> onFit = null) { Contracts.CheckValueOrNull(options); CheckUserValues(label, features, weights, onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { options.LabelColumnName = labelName; options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; var trainer = new FastTreeRegressionTrainer(env, options); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <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="label">The label, or dependent variable.</param> /// <param name="features">The features, or independent variables.</param> /// <param name="weights">The optional example weights.</param> /// <param name="options">Advanced arguments to the algorithm.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained, as well as the calibrator on top of that model. Note that this action cannot change the /// result in any way; it is only a way for the caller to be informed about what was learnt.</param> /// <returns>The set of output columns including in order the predicted binary classification score (which will range /// from negative to positive infinity), and the predicted label.</returns> /// <seealso cref="OnlineGradientDescentTrainer"/>. /// <returns>The predicted output.</returns> public static Scalar <float> OnlineGradientDescent(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights, OnlineGradientDescentTrainer.Options options, Action <LinearRegressionModelParameters> onFit = null) { Contracts.CheckValue(label, nameof(label)); Contracts.CheckValue(features, nameof(features)); Contracts.CheckValueOrNull(weights); Contracts.CheckValue(options, nameof(options)); Contracts.CheckValueOrNull(onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { options.LabelColumnName = labelName; options.FeatureColumnName = featuresName; var trainer = new OnlineGradientDescentTrainer(env, options); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <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="label">The label, or dependent variable.</param> /// <param name="features">The features, or independent variables.</param> /// <param name="weights">The optional example weights.</param> /// <param name="l2Regularization">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="numberOfIterations">The maximum number of passes to perform over the data.</param> /// <param name="lossFunction">The custom loss, if unspecified will be <see cref="SquaredLoss"/>.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained. Note that this action cannot change the result in any way; it is only a way for the caller to /// be informed about what was learnt.</param> /// <returns>The predicted output.</returns> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Static/SDCARegression.cs)] /// ]]></format> /// </example> public static Scalar <float> Sdca(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights = null, float?l2Regularization = null, float?l1Threshold = null, int?numberOfIterations = null, ISupportSdcaRegressionLoss lossFunction = null, Action <LinearRegressionModelParameters> onFit = null) { Contracts.CheckValue(label, nameof(label)); Contracts.CheckValue(features, nameof(features)); Contracts.CheckValueOrNull(weights); Contracts.CheckParam(!(l2Regularization < 0), nameof(l2Regularization), "Must not be negative, if specified."); Contracts.CheckParam(!(l1Threshold < 0), nameof(l1Threshold), "Must not be negative, if specified."); Contracts.CheckParam(!(numberOfIterations < 1), nameof(numberOfIterations), "Must be positive if specified"); Contracts.CheckValueOrNull(lossFunction); Contracts.CheckValueOrNull(onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { var trainer = new SdcaRegressionTrainer(env, labelName, featuresName, weightsName, lossFunction, l2Regularization, l1Threshold, numberOfIterations); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <summary> /// Predict matrix entry using matrix factorization /// </summary> /// <typeparam name="T">The type of physical value of matrix's row and column index. It must be an integer type such as uint.</typeparam> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="label">The label variable.</param> /// <param name="matrixColumnIndex">The column index of the considered matrix.</param> /// <param name="matrixRowIndex">The row index of the considered matrix.</param> /// <param name="options">Advanced algorithm settings.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the model that was trained. Note that this action cannot change the result in any way; it is only a way for the caller to /// be informed about what was learnt.</param> /// <returns>The predicted output.</returns> public static Scalar <float> MatrixFactorization <T>(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Key <T> matrixColumnIndex, Key <T> matrixRowIndex, MatrixFactorizationTrainer.Options options, Action <MatrixFactorizationPredictor> onFit = null) { Contracts.CheckValue(label, nameof(label)); Contracts.CheckValue(matrixColumnIndex, nameof(matrixColumnIndex)); Contracts.CheckValue(matrixRowIndex, nameof(matrixRowIndex)); Contracts.CheckValue(options, nameof(options)); Contracts.CheckValueOrNull(onFit); var rec = new MatrixFactorizationReconciler <T>((env, labelColName, matrixColumnIndexColName, matrixRowIndexColName) => { options.MatrixColumnIndexColumnName = matrixColumnIndexColName; options.MatrixRowIndexColumnName = matrixRowIndexColName; options.LabelColumnName = labelColName; var trainer = new MatrixFactorizationTrainer(env, options); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } else { return(trainer); } }, label, matrixColumnIndex, matrixRowIndex); return(rec.Output); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Trainers.LogisticRegression"/> trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="label">The label, or dependent variable.</param> /// <param name="features">The features, or independent variables.</param> /// <param name="weights">The optional example weights.</param> /// <param name="enforceNonNegativity">Enforce non-negative weights.</param> /// <param name="l1Regularization">Weight of L1 regularization term.</param> /// <param name="l2Regularization">Weight of L2 regularization term.</param> /// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.LogisticRegression"/>. Low=faster, less accurate.</param> /// <param name="optimizationTolerance">Threshold for optimizer convergence.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained. Note that this action cannot change the result in any way; it is only a way for the caller to /// be informed about what was learnt.</param> /// <returns>The predicted output.</returns> public static Scalar <float> PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights = null, float l1Regularization = Options.Defaults.L1Regularization, float l2Regularization = Options.Defaults.L2Regularization, float optimizationTolerance = Options.Defaults.OptimizationTolerance, int historySize = Options.Defaults.HistorySize, bool enforceNonNegativity = Options.Defaults.EnforceNonNegativity, Action <PoissonRegressionModelParameters> onFit = null) { LbfgsStaticUtils.ValidateParams(label, features, weights, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity, onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { var trainer = new PoissonRegression(env, labelName, featuresName, weightsName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <summary> /// Predict a target using a tree regression model trained with the <see cref="LightGbmRegressorTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="label">The label column.</param> /// <param name="features">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> /// <param name="advancedSettings">Algorithm advanced settings.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained. Note that this action cannot change the result in any way; /// it is only a way for the caller to be informed about what was learnt.</param> /// <returns>The Score output column indicating the predicted value.</returns> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[LightGBM](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Static/LightGBMRegression.cs)] /// ]]></format> /// </example> public static Scalar <float> LightGbm(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights = null, int?numLeaves = null, int?minDataPerLeaf = null, double?learningRate = null, int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, Action <LightGbmArguments> advancedSettings = null, Action <LightGbmRegressionModelParameters> onFit = null) { CheckUserValues(label, features, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings, onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { var trainer = new LightGbmRegressorTrainer(env, labelName, featuresName, weightsName, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <summary> /// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Learners.LogisticRegression"/> trainer. /// </summary> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="label">The label, or dependent variable.</param> /// <param name="features">The features, or independent variables.</param> /// <param name="weights">The optional example weights.</param> /// <param name="options">Advanced arguments to the algorithm.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained. Note that this action cannot change the result in any way; it is only a way for the caller to /// be informed about what was learnt.</param> /// <returns>The predicted output.</returns> public static Scalar <float> PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights, PoissonRegression.Options options, Action <PoissonRegressionModelParameters> onFit = null) { Contracts.CheckValue(label, nameof(label)); Contracts.CheckValue(features, nameof(features)); Contracts.CheckValue(options, nameof(options)); Contracts.CheckValueOrNull(onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { options.LabelColumn = labelName; options.FeatureColumn = featuresName; options.WeightColumn = weightsName != null ? Optional <string> .Explicit(weightsName) : Optional <string> .Implicit(DefaultColumnNames.Weight); var trainer = new PoissonRegression(env, options); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <summary> /// Predict matrix entry using matrix factorization /// </summary> /// <typeparam name="T">The type of physical value of matrix's row and column index. It must be an integer type such as uint.</typeparam> /// <param name="catalog">The regression catalog trainer object.</param> /// <param name="label">The label variable.</param> /// <param name="matrixColumnIndex">The column index of the considered matrix.</param> /// <param name="matrixRowIndex">The row index of the considered matrix.</param> /// <param name="regularizationCoefficient">The frobenius norms of factor matrices.</param> /// <param name="approximationRank">Rank of the two factor matrices whose product is used to approximate the consdered matrix</param> /// <param name="learningRate">Initial learning rate.</param> /// <param name="numIterations">Number of training iterations.</param> /// <param name="advancedSettings">A delegate to set more settings.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the model that was trained. Note that this action cannot change the result in any way; it is only a way for the caller to /// be informed about what was learnt.</param> /// <returns>The predicted output.</returns> public static Scalar <float> MatrixFactorization <T>(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Key <T> matrixColumnIndex, Key <T> matrixRowIndex, float regularizationCoefficient = 0.1f, int approximationRank = 8, float learningRate = 0.1f, int numIterations = 20, Action <MatrixFactorizationTrainer.Arguments> advancedSettings = null, Action <MatrixFactorizationPredictor> onFit = null) { Contracts.CheckValue(label, nameof(label)); Contracts.CheckValue(matrixColumnIndex, nameof(matrixColumnIndex)); Contracts.CheckValue(matrixRowIndex, nameof(matrixRowIndex)); Contracts.CheckParam(regularizationCoefficient >= 0, nameof(regularizationCoefficient), "Must be non-negative"); Contracts.CheckParam(approximationRank > 0, nameof(approximationRank), "Must be positive"); Contracts.CheckParam(learningRate > 0, nameof(learningRate), "Must be positive"); Contracts.CheckParam(numIterations > 0, nameof(numIterations), "Must be positive"); Contracts.CheckValueOrNull(advancedSettings); Contracts.CheckValueOrNull(onFit); var rec = new MatrixFactorizationReconciler <T>((env, labelColName, matrixColumnIndexColName, matrixRowIndexColName) => { var trainer = new MatrixFactorizationTrainer(env, matrixColumnIndexColName, matrixRowIndexColName, labelColName, advancedSettings: args => { args.Lambda = regularizationCoefficient; args.K = approximationRank; args.Eta = learningRate; args.NumIterations = numIterations; // The previous settings may be overwritten by the line below. advancedSettings?.Invoke(args); }); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } else { return(trainer); } }, label, matrixColumnIndex, matrixRowIndex); return(rec.Output); }
/// <summary> /// FastTree <see cref="RegressionCatalog"/> extension method. /// Predicts 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="label">The label column.</param> /// <param name="features">The features column.</param> /// <param name="weights">The optional weights column.</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 allowed in a leaf of a regression tree, out of the subsampled data.</param> /// <param name="learningRate">The learning rate.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained. Note that this action cannot change the result in any way; /// it is only a way for the caller to be informed about what was learnt.</param> /// <returns>The Score output column indicating the predicted value.</returns> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[FastTree](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Static/FastTreeRegression.cs)] /// ]]></format> /// </example> public static Scalar <float> FastTree(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights = null, int numberOfLeaves = Defaults.NumberOfLeaves, int numberOfTrees = Defaults.NumberOfTrees, int minimumExampleCountPerLeaf = Defaults.MinimumExampleCountPerLeaf, double learningRate = Defaults.LearningRate, Action <FastTreeRegressionModelParameters> onFit = null) { CheckUserValues(label, features, weights, numberOfLeaves, numberOfTrees, minimumExampleCountPerLeaf, learningRate, onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { var trainer = new FastTreeRegressionTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, numberOfTrees, minimumExampleCountPerLeaf, learningRate); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }
/// <summary> /// Predict a target using a tree regression model trained with the <see cref="LightGbmRegressorTrainer"/>. /// </summary> /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> /// <param name="label">The label column.</param> /// <param name="features">The features column.</param> /// <param name="weights">The weights column.</param> /// <param name="options">Algorithm advanced settings.</param> /// <param name="onFit">A delegate that is called every time the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive /// the linear model that was trained. Note that this action cannot change the result in any way; /// it is only a way for the caller to be informed about what was learnt.</param> /// <returns>The Score output column indicating the predicted value.</returns> public static Scalar <float> LightGbm(this RegressionCatalog.RegressionTrainers catalog, Scalar <float> label, Vector <float> features, Scalar <float> weights, Options options, Action <LightGbmRegressionModelParameters> onFit = null) { CheckUserValues(label, features, weights, options, onFit); var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { options.LabelColumn = labelName; options.FeatureColumn = featuresName; options.WeightColumn = weightsName != null ? Optional <string> .Explicit(weightsName) : Optional <string> .Implicit(DefaultColumnNames.Weight); var trainer = new LightGbmRegressorTrainer(env, options); if (onFit != null) { return(trainer.WithOnFitDelegate(trans => onFit(trans.Model))); } return(trainer); }, label, features, weights); return(rec.Score); }