|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | + |
| 5 | +using Microsoft.ML.Runtime; |
| 6 | +using Microsoft.ML.Runtime.Data; |
| 7 | +using Microsoft.ML.Trainers.HalLearners; |
| 8 | +using Microsoft.ML.Trainers.SymSgd; |
| 9 | +using System; |
| 10 | + |
| 11 | +namespace Microsoft.ML |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// The trainer context extensions for the <see cref="OlsLinearRegressionTrainer"/> and <see cref="SymSgdClassificationTrainer"/>. |
| 15 | + /// </summary> |
| 16 | + public static class HalLearnersCatalog |
| 17 | + { |
| 18 | + /// <summary> |
| 19 | + /// Predict a target using a linear regression model trained with the <see cref="OlsLinearRegressionTrainer"/>. |
| 20 | + /// </summary> |
| 21 | + /// <param name="ctx">The <see cref="RegressionContext"/>.</param> |
| 22 | + /// <param name="label">The label column.</param> |
| 23 | + /// <param name="features">The features column.</param> |
| 24 | + /// <param name="weights">The weights column.</param> |
| 25 | + /// <param name="advancedSettings">Algorithm advanced settings.</param> |
| 26 | + public static OlsLinearRegressionTrainer OrdinaryLeastSquares(this RegressionContext.RegressionTrainers ctx, |
| 27 | + string label, |
| 28 | + string features, |
| 29 | + string weights = null, |
| 30 | + Action<OlsLinearRegressionTrainer.Arguments> advancedSettings = null) |
| 31 | + { |
| 32 | + Contracts.CheckValue(ctx, nameof(ctx)); |
| 33 | + var env = CatalogUtils.GetEnvironment(ctx); |
| 34 | + return new OlsLinearRegressionTrainer(env, label, features, weights, advancedSettings); |
| 35 | + } |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Predict a target using a linear regression model trained with the <see cref="SymSgdClassificationTrainer"/>. |
| 39 | + /// </summary> |
| 40 | + /// <param name="ctx">The <see cref="RegressionContext"/>.</param> |
| 41 | + /// <param name="label">The label column.</param> |
| 42 | + /// <param name="features">The features column.</param> |
| 43 | + /// <param name="advancedSettings">Algorithm advanced settings.</param> |
| 44 | + public static SymSgdClassificationTrainer SymbolicStochasticGradientDescent(this RegressionContext.RegressionTrainers ctx, |
| 45 | + string label, |
| 46 | + string features, |
| 47 | + Action<SymSgdClassificationTrainer.Arguments> advancedSettings = null) |
| 48 | + { |
| 49 | + Contracts.CheckValue(ctx, nameof(ctx)); |
| 50 | + var env = CatalogUtils.GetEnvironment(ctx); |
| 51 | + return new SymSgdClassificationTrainer(env, label, features, advancedSettings); |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments