|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 | // See the LICENSE file in the project root for more information.
|
4 | 4 |
|
| 5 | +using System.IO; |
5 | 6 | using Microsoft.ML.Data;
|
6 | 7 | using Microsoft.ML.Runtime;
|
7 | 8 | using Microsoft.ML.Trainers.LightGbm;
|
@@ -67,6 +68,22 @@ public static LightGbmRegressionTrainer LightGbm(this RegressionCatalog.Regressi
|
67 | 68 | return new LightGbmRegressionTrainer(env, options);
|
68 | 69 | }
|
69 | 70 |
|
| 71 | + /// <summary> |
| 72 | + /// Create <see cref="LightGbmRegressionTrainer"/> from a pre-trained LightGBM model, which predicts a target using a gradient boosting decision tree regression. |
| 73 | + /// </summary> |
| 74 | + /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> |
| 75 | + /// <param name="lightGbmModel"> A pre-trained <see cref="System.IO.Stream"/> of a LightGBM model file inferencing</param> |
| 76 | + /// <param name="featureColumnName">The name of the feature column. The column data must be a known-sized vector of <see cref="System.Single"/>.</param> |
| 77 | + public static LightGbmRegressionTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, |
| 78 | + Stream lightGbmModel, |
| 79 | + string featureColumnName = DefaultColumnNames.Features |
| 80 | + ) |
| 81 | + { |
| 82 | + Contracts.CheckValue(catalog, nameof(catalog)); |
| 83 | + var env = CatalogUtils.GetEnvironment(catalog); |
| 84 | + return new LightGbmRegressionTrainer(env, lightGbmModel, featureColumnName); |
| 85 | + } |
| 86 | + |
70 | 87 | /// <summary>
|
71 | 88 | /// Create <see cref="LightGbmBinaryTrainer"/>, which predicts a target using a gradient boosting decision tree binary classification.
|
72 | 89 | /// </summary>
|
@@ -119,6 +136,22 @@ public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.Bi
|
119 | 136 | return new LightGbmBinaryTrainer(env, options);
|
120 | 137 | }
|
121 | 138 |
|
| 139 | + /// <summary> |
| 140 | + /// Create <see cref="LightGbmBinaryTrainer"/> from a pre-trained LightGBM model, which predicts a target using a gradient boosting decision tree binary classification. |
| 141 | + /// </summary> |
| 142 | + /// <param name="catalog">The <see cref="BinaryClassificationCatalog"/>.</param> |
| 143 | + /// <param name="lightGbmModel"> A pre-trained <see cref="System.IO.Stream"/> of a LightGBM model file inferencing</param> |
| 144 | + /// <param name="featureColumnName">The name of the feature column. The column data must be a known-sized vector of <see cref="System.Single"/>.</param> |
| 145 | + public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, |
| 146 | + Stream lightGbmModel, |
| 147 | + string featureColumnName = DefaultColumnNames.Features |
| 148 | + ) |
| 149 | + { |
| 150 | + Contracts.CheckValue(catalog, nameof(catalog)); |
| 151 | + var env = CatalogUtils.GetEnvironment(catalog); |
| 152 | + return new LightGbmBinaryTrainer(env, lightGbmModel, featureColumnName); |
| 153 | + } |
| 154 | + |
122 | 155 | /// <summary>
|
123 | 156 | /// Create <see cref="LightGbmRankingTrainer"/>, which predicts a target using a gradient boosting decision tree ranking model.
|
124 | 157 | /// </summary>
|
@@ -174,6 +207,22 @@ public static LightGbmRankingTrainer LightGbm(this RankingCatalog.RankingTrainer
|
174 | 207 | return new LightGbmRankingTrainer(env, options);
|
175 | 208 | }
|
176 | 209 |
|
| 210 | + /// <summary> |
| 211 | + /// Create <see cref="LightGbmRankingTrainer"/> from a pre-trained LightGBM model, which predicts a target using a gradient boosting decision tree ranking model. |
| 212 | + /// </summary> |
| 213 | + /// <param name="catalog">The <see cref="RankingCatalog"/>.</param> |
| 214 | + /// <param name="lightGbmModel"> A pre-trained <see cref="System.IO.Stream"/> of a LightGBM model file inferencing</param> |
| 215 | + /// <param name="featureColumnName">The name of the feature column. The column data must be a known-sized vector of <see cref="System.Single"/>.</param> |
| 216 | + public static LightGbmRankingTrainer LightGbm(this RankingCatalog.RankingTrainers catalog, |
| 217 | + Stream lightGbmModel, |
| 218 | + string featureColumnName = DefaultColumnNames.Features |
| 219 | + ) |
| 220 | + { |
| 221 | + Contracts.CheckValue(catalog, nameof(catalog)); |
| 222 | + var env = CatalogUtils.GetEnvironment(catalog); |
| 223 | + return new LightGbmRankingTrainer(env, lightGbmModel, featureColumnName); |
| 224 | + } |
| 225 | + |
177 | 226 | /// <summary>
|
178 | 227 | /// Create <see cref="LightGbmMulticlassTrainer"/>, which predicts a target using a gradient boosting decision tree multiclass classification model.
|
179 | 228 | /// </summary>
|
@@ -225,5 +274,21 @@ public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCa
|
225 | 274 | var env = CatalogUtils.GetEnvironment(catalog);
|
226 | 275 | return new LightGbmMulticlassTrainer(env, options);
|
227 | 276 | }
|
| 277 | + |
| 278 | + /// <summary> |
| 279 | + /// Create <see cref="LightGbmMulticlassTrainer"/> from a pre-trained LightGBM model, which predicts a target using a gradient boosting decision tree multiclass classification model. |
| 280 | + /// </summary> |
| 281 | + /// <param name="catalog">The <see cref="MulticlassClassificationCatalog"/>.</param> |
| 282 | + /// <param name="lightGbmModel"> A pre-trained <see cref="System.IO.Stream"/> of a LightGBM model file inferencing</param> |
| 283 | + /// <param name="featureColumnName">The name of the feature column. The column data must be a known-sized vector of <see cref="System.Single"/>.</param> |
| 284 | + public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, |
| 285 | + Stream lightGbmModel, |
| 286 | + string featureColumnName = DefaultColumnNames.Features |
| 287 | + ) |
| 288 | + { |
| 289 | + Contracts.CheckValue(catalog, nameof(catalog)); |
| 290 | + var env = CatalogUtils.GetEnvironment(catalog); |
| 291 | + return new LightGbmMulticlassTrainer(env, lightGbmModel, featureColumnName); |
| 292 | + } |
228 | 293 | }
|
229 | 294 | }
|
0 commit comments