From 42ca927deeed4d4c7228a9c709178f6a67637649 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Tue, 26 Feb 2019 14:15:21 -0800 Subject: [PATCH 01/11] Move Learner* input base and Transform* input base out of Entrypoints namespace --- src/Microsoft.ML.Data/EntryPoints/Cache.cs | 1 + .../EntryPoints/InputBase.cs | 203 +----------------- .../Prediction/Calibrator.cs | 1 + .../Training/LearnerInputBase.cs | 197 +++++++++++++++++ ...atureContributionCalculationTransformer.cs | 1 + .../Transforms/NopTransform.cs | 1 + .../Transforms/TransformInputBase.cs | 25 +++ .../FeatureCombiner.cs | 1 + .../ModelOperations.cs | 1 + .../OneVersusAllMacro.cs | 1 + .../ImageGrayscale.cs | 2 +- .../ImageLoader.cs | 2 +- .../ImagePixelExtractor.cs | 1 + .../ImageResizer.cs | 1 + .../VectorToImageTransform.cs | 2 +- .../LightGbmArguments.cs | 1 + .../LightGbmBinaryTrainer.cs | 1 + .../LightGbmRankingTrainer.cs | 1 + .../LightGbmRegressionTrainer.cs | 1 + .../FactorizationMachineTrainer.cs | 1 + 20 files changed, 240 insertions(+), 205 deletions(-) create mode 100644 src/Microsoft.ML.Data/Training/LearnerInputBase.cs create mode 100644 src/Microsoft.ML.Data/Transforms/TransformInputBase.cs diff --git a/src/Microsoft.ML.Data/EntryPoints/Cache.cs b/src/Microsoft.ML.Data/EntryPoints/Cache.cs index a518352a27..f51a9a74df 100644 --- a/src/Microsoft.ML.Data/EntryPoints/Cache.cs +++ b/src/Microsoft.ML.Data/EntryPoints/Cache.cs @@ -9,6 +9,7 @@ using Microsoft.ML.Data; using Microsoft.ML.Data.IO; using Microsoft.ML.EntryPoints; +using Microsoft.ML.Transforms; [assembly: LoadableClass(typeof(void), typeof(Cache), null, typeof(SignatureEntryPointModule), "Cache")] namespace Microsoft.ML.EntryPoints diff --git a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs index 3e991829f4..340795a967 100644 --- a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs +++ b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs @@ -2,31 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; using Microsoft.Data.DataView; using Microsoft.ML.CommandLine; using Microsoft.ML.Data; -using Microsoft.ML.Data.IO; -using Microsoft.ML.Internal.Calibration; namespace Microsoft.ML.EntryPoints { - /// - /// The base class for all transform inputs. - /// - [TlcModule.EntryPointKind(typeof(CommonInputs.ITransformInput))] - public abstract class TransformInputBase - { - /// - /// The input dataset. Used only in entry-point methods, since the normal API mechanism for feeding in a dataset to - /// create an is to use the method. - /// - [BestFriend] - [Argument(ArgumentType.Required, HelpText = "Input dataset", Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly, SortOrder = 1)] - internal IDataView Data; - } - [BestFriend] internal enum CachingOptions { @@ -36,89 +17,11 @@ internal enum CachingOptions None } - /// - /// The base class for all learner inputs. - /// - [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInput))] - public abstract class LearnerInputBase - { - /// - /// The data to be used for training. Used only in entry-points, since in the API the expected mechanism is - /// that the user will use the or some other train - /// method. - /// - [BestFriend] - [Argument(ArgumentType.Required, ShortName = "data", HelpText = "The data to be used for training", SortOrder = 1, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - internal IDataView TrainingData; - - /// - /// Column to use for features. - /// - [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for features", ShortName = "feat", SortOrder = 2, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string FeatureColumn = DefaultColumnNames.Features; - - /// - /// Normalize option for the feature column. Used only in entry-points, since in the API the user is expected to do this themselves. - /// - [BestFriend] - [Argument(ArgumentType.AtMostOnce, HelpText = "Normalize option for the feature column", ShortName = "norm", SortOrder = 5, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - internal NormalizeOption NormalizeFeatures = NormalizeOption.Auto; - - /// - /// Whether learner should cache input training data. Used only in entry-points, since the intended API mechanism - /// is that the user will use the or other method - /// like . - /// - [BestFriend] - [Argument(ArgumentType.LastOccurenceWins, HelpText = "Whether learner should cache input training data", ShortName = "cache", SortOrder = 6, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - internal CachingOptions Caching = CachingOptions.Auto; - } - - /// - /// The base class for all learner inputs that support a Label column. - /// - [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithLabel))] - public abstract class LearnerInputBaseWithLabel : LearnerInputBase - { - /// - /// Column to use for labels. - /// - [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for labels", ShortName = "lab", SortOrder = 3, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string LabelColumn = DefaultColumnNames.Label; - } - - // REVIEW: This is a known antipattern, but the solution involves the decorator pattern which can't be used in this case. - /// - /// The base class for all learner inputs that support a weight column. - /// - [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithWeight))] - public abstract class LearnerInputBaseWithWeight : LearnerInputBaseWithLabel - { - /// - /// Column to use for example weight. - /// - [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string WeightColumn = null; - } - - /// - /// The base class for all unsupervised learner inputs that support a weight column. - /// - [TlcModule.EntryPointKind(typeof(CommonInputs.IUnsupervisedTrainerWithWeight))] - public abstract class UnsupervisedLearnerInputBaseWithWeight : LearnerInputBase - { - /// - /// Column to use for example weight. - /// - [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string WeightColumn = null; - } - /// /// The base class for all evaluators inputs. /// [TlcModule.EntryPointKind(typeof(CommonInputs.IEvaluatorInput))] - public abstract class EvaluateInputBase + internal abstract class EvaluateInputBase { [Argument(ArgumentType.Required, ShortName = "data", HelpText = "The data to be used for evaluation.", SortOrder = 1, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] public IDataView Data; @@ -127,110 +30,6 @@ public abstract class EvaluateInputBase public string NameColumn = DefaultColumnNames.Name; } - [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithGroupId))] - public abstract class LearnerInputBaseWithGroupId : LearnerInputBaseWithWeight - { - /// - /// Column to use for example groupId. - /// - [Argument(ArgumentType.AtMostOnce, Name = "GroupIdColumn", HelpText = "Column to use for example groupId", ShortName = "groupId", SortOrder = 5, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string GroupIdColumn = null; - } - - [BestFriend] - internal static class LearnerEntryPointsUtils - { - public static string FindColumn(IExceptionContext ectx, DataViewSchema schema, Optional value) - { - Contracts.CheckValueOrNull(ectx); - ectx.CheckValue(schema, nameof(schema)); - ectx.CheckValue(value, nameof(value)); - - if (string.IsNullOrEmpty(value?.Value)) - return null; - if (!schema.TryGetColumnIndex(value, out int col)) - { - if (value.IsExplicit) - throw ectx.Except("Column '{0}' not found", value); - return null; - } - return value; - } - - public static TOut Train(IHost host, TArg input, - Func createTrainer, - Func getLabel = null, - Func getWeight = null, - Func getGroup = null, - Func getName = null, - Func>> getCustom = null, - ICalibratorTrainerFactory calibrator = null, - int maxCalibrationExamples = 0) - where TArg : LearnerInputBase - where TOut : CommonOutputs.TrainerOutput, new() - { - using (var ch = host.Start("Training")) - { - var schema = input.TrainingData.Schema; - var feature = FindColumn(ch, schema, input.FeatureColumn); - var label = getLabel?.Invoke(); - var weight = getWeight?.Invoke(); - var group = getGroup?.Invoke(); - var name = getName?.Invoke(); - var custom = getCustom?.Invoke(); - - var trainer = createTrainer(); - - IDataView view = input.TrainingData; - TrainUtils.AddNormalizerIfNeeded(host, ch, trainer, ref view, feature, input.NormalizeFeatures); - - ch.Trace("Binding columns"); - var roleMappedData = new RoleMappedData(view, label, feature, group, weight, name, custom); - - RoleMappedData cachedRoleMappedData = roleMappedData; - Cache.CachingType? cachingType = null; - switch (input.Caching) - { - case CachingOptions.Memory: - { - cachingType = Cache.CachingType.Memory; - break; - } - case CachingOptions.Disk: - { - cachingType = Cache.CachingType.Disk; - break; - } - case CachingOptions.Auto: - { - // REVIEW: we should switch to hybrid caching in future. - if (!(input.TrainingData is BinaryLoader) && trainer.Info.WantCaching) - // default to Memory so mml is on par with maml - cachingType = Cache.CachingType.Memory; - break; - } - case CachingOptions.None: - break; - default: - throw ch.ExceptParam(nameof(input.Caching), "Unknown option for caching: '{0}'", input.Caching); - } - - if (cachingType.HasValue) - { - var cacheView = Cache.CacheData(host, new Cache.CacheInput() - { - Data = roleMappedData.Data, - Caching = cachingType.Value - }).OutputData; - cachedRoleMappedData = new RoleMappedData(cacheView, roleMappedData.Schema.GetColumnRoleNames()); - } - - var predictor = TrainUtils.Train(host, ch, cachedRoleMappedData, trainer, calibrator, maxCalibrationExamples); - return new TOut() { PredictorModel = new PredictorModelImpl(host, roleMappedData, input.TrainingData, predictor) }; - } - } - } - /// /// Common input interfaces for TLC components. /// diff --git a/src/Microsoft.ML.Data/Prediction/Calibrator.cs b/src/Microsoft.ML.Data/Prediction/Calibrator.cs index f230332671..20916ff4f8 100644 --- a/src/Microsoft.ML.Data/Prediction/Calibrator.cs +++ b/src/Microsoft.ML.Data/Prediction/Calibrator.cs @@ -20,6 +20,7 @@ using Microsoft.ML.Model; using Microsoft.ML.Model.OnnxConverter; using Microsoft.ML.Model.Pfa; +using Microsoft.ML.Transforms; using Newtonsoft.Json.Linq; [assembly: LoadableClass(PlattCalibratorTrainer.Summary, typeof(PlattCalibratorTrainer), null, typeof(SignatureCalibrator), diff --git a/src/Microsoft.ML.Data/Training/LearnerInputBase.cs b/src/Microsoft.ML.Data/Training/LearnerInputBase.cs new file mode 100644 index 0000000000..a929c0c8ed --- /dev/null +++ b/src/Microsoft.ML.Data/Training/LearnerInputBase.cs @@ -0,0 +1,197 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using Microsoft.Data.DataView; +using Microsoft.ML.CommandLine; +using Microsoft.ML.Data; +using Microsoft.ML.Data.IO; +using Microsoft.ML.EntryPoints; +using Microsoft.ML.Internal.Calibration; + +namespace Microsoft.ML.Trainers +{ + /// + /// The base class for all learner inputs. + /// + [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInput))] + public abstract class LearnerInputBase + { + /// + /// The data to be used for training. Used only in entry-points, since in the API the expected mechanism is + /// that the user will use the or some other train + /// method. + /// + [BestFriend] + [Argument(ArgumentType.Required, ShortName = "data", HelpText = "The data to be used for training", SortOrder = 1, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + internal IDataView TrainingData; + + /// + /// Column to use for features. + /// + [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for features", ShortName = "feat", SortOrder = 2, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + public string FeatureColumn = DefaultColumnNames.Features; + + /// + /// Normalize option for the feature column. Used only in entry-points, since in the API the user is expected to do this themselves. + /// + [BestFriend] + [Argument(ArgumentType.AtMostOnce, HelpText = "Normalize option for the feature column", ShortName = "norm", SortOrder = 5, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + internal NormalizeOption NormalizeFeatures = NormalizeOption.Auto; + + /// + /// Whether learner should cache input training data. Used only in entry-points, since the intended API mechanism + /// is that the user will use the or other method + /// like . + /// + [BestFriend] + [Argument(ArgumentType.LastOccurenceWins, HelpText = "Whether learner should cache input training data", ShortName = "cache", SortOrder = 6, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + internal CachingOptions Caching = CachingOptions.Auto; + } + + /// + /// The base class for all learner inputs that support a Label column. + /// + [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithLabel))] + public abstract class LearnerInputBaseWithLabel : LearnerInputBase + { + /// + /// Column to use for labels. + /// + [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for labels", ShortName = "lab", SortOrder = 3, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + public string LabelColumn = DefaultColumnNames.Label; + } + + // REVIEW: This is a known antipattern, but the solution involves the decorator pattern which can't be used in this case. + /// + /// The base class for all learner inputs that support a weight column. + /// + [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithWeight))] + public abstract class LearnerInputBaseWithWeight : LearnerInputBaseWithLabel + { + /// + /// Column to use for example weight. + /// + [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + public string WeightColumn = null; + } + + /// + /// The base class for all unsupervised learner inputs that support a weight column. + /// + [TlcModule.EntryPointKind(typeof(CommonInputs.IUnsupervisedTrainerWithWeight))] + public abstract class UnsupervisedLearnerInputBaseWithWeight : LearnerInputBase + { + /// + /// Column to use for example weight. + /// + [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + public string WeightColumn = null; + } + + [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithGroupId))] + public abstract class LearnerInputBaseWithGroupId : LearnerInputBaseWithWeight + { + /// + /// Column to use for example groupId. + /// + [Argument(ArgumentType.AtMostOnce, Name = "GroupIdColumn", HelpText = "Column to use for example groupId", ShortName = "groupId", SortOrder = 5, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + public string GroupIdColumn = null; + } + + [BestFriend] + internal static class LearnerEntryPointsUtils + { + public static string FindColumn(IExceptionContext ectx, DataViewSchema schema, Optional value) + { + Contracts.CheckValueOrNull(ectx); + ectx.CheckValue(schema, nameof(schema)); + ectx.CheckValue(value, nameof(value)); + + if (string.IsNullOrEmpty(value?.Value)) + return null; + if (!schema.TryGetColumnIndex(value, out int col)) + { + if (value.IsExplicit) + throw ectx.Except("Column '{0}' not found", value); + return null; + } + return value; + } + + public static TOut Train(IHost host, TArg input, + Func createTrainer, + Func getLabel = null, + Func getWeight = null, + Func getGroup = null, + Func getName = null, + Func>> getCustom = null, + ICalibratorTrainerFactory calibrator = null, + int maxCalibrationExamples = 0) + where TArg : LearnerInputBase + where TOut : CommonOutputs.TrainerOutput, new() + { + using (var ch = host.Start("Training")) + { + var schema = input.TrainingData.Schema; + var feature = FindColumn(ch, schema, input.FeatureColumn); + var label = getLabel?.Invoke(); + var weight = getWeight?.Invoke(); + var group = getGroup?.Invoke(); + var name = getName?.Invoke(); + var custom = getCustom?.Invoke(); + + var trainer = createTrainer(); + + IDataView view = input.TrainingData; + TrainUtils.AddNormalizerIfNeeded(host, ch, trainer, ref view, feature, input.NormalizeFeatures); + + ch.Trace("Binding columns"); + var roleMappedData = new RoleMappedData(view, label, feature, group, weight, name, custom); + + RoleMappedData cachedRoleMappedData = roleMappedData; + Cache.CachingType? cachingType = null; + switch (input.Caching) + { + case CachingOptions.Memory: + { + cachingType = Cache.CachingType.Memory; + break; + } + case CachingOptions.Disk: + { + cachingType = Cache.CachingType.Disk; + break; + } + case CachingOptions.Auto: + { + // REVIEW: we should switch to hybrid caching in future. + if (!(input.TrainingData is BinaryLoader) && trainer.Info.WantCaching) + // default to Memory so mml is on par with maml + cachingType = Cache.CachingType.Memory; + break; + } + case CachingOptions.None: + break; + default: + throw ch.ExceptParam(nameof(input.Caching), "Unknown option for caching: '{0}'", input.Caching); + } + + if (cachingType.HasValue) + { + var cacheView = Cache.CacheData(host, new Cache.CacheInput() + { + Data = roleMappedData.Data, + Caching = cachingType.Value + }).OutputData; + cachedRoleMappedData = new RoleMappedData(cacheView, roleMappedData.Schema.GetColumnRoleNames()); + } + + var predictor = TrainUtils.Train(host, ch, cachedRoleMappedData, trainer, calibrator, maxCalibrationExamples); + return new TOut() { PredictorModel = new PredictorModelImpl(host, roleMappedData, input.TrainingData, predictor) }; + } + } + } +} diff --git a/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs b/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs index f6fb7c81d7..8f1eee6d62 100644 --- a/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs +++ b/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs @@ -13,6 +13,7 @@ using Microsoft.ML.Internal.Internallearn; using Microsoft.ML.Internal.Utilities; using Microsoft.ML.Model; +using Microsoft.ML.Transforms; [assembly: LoadableClass(FeatureContributionCalculatingTransformer.Summary, typeof(FeatureContributionCalculatingTransformer), null, typeof(SignatureLoadModel), FeatureContributionCalculatingTransformer.FriendlyName, FeatureContributionCalculatingTransformer.LoaderSignature)] diff --git a/src/Microsoft.ML.Data/Transforms/NopTransform.cs b/src/Microsoft.ML.Data/Transforms/NopTransform.cs index 8da4ef60f6..9c4b7c2655 100644 --- a/src/Microsoft.ML.Data/Transforms/NopTransform.cs +++ b/src/Microsoft.ML.Data/Transforms/NopTransform.cs @@ -9,6 +9,7 @@ using Microsoft.ML.Data; using Microsoft.ML.EntryPoints; using Microsoft.ML.Model; +using Microsoft.ML.Transforms; [assembly: LoadableClass(NopTransform.Summary, typeof(NopTransform), null, typeof(SignatureLoadDataTransform), "", NopTransform.LoaderSignature)] diff --git a/src/Microsoft.ML.Data/Transforms/TransformInputBase.cs b/src/Microsoft.ML.Data/Transforms/TransformInputBase.cs new file mode 100644 index 0000000000..174636092f --- /dev/null +++ b/src/Microsoft.ML.Data/Transforms/TransformInputBase.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Data.DataView; +using Microsoft.ML.CommandLine; +using Microsoft.ML.EntryPoints; + +namespace Microsoft.ML.Transforms +{ + /// + /// The base class for all transform inputs. + /// + [TlcModule.EntryPointKind(typeof(CommonInputs.ITransformInput))] + public abstract class TransformInputBase + { + /// + /// The input dataset. Used only in entry-point methods, since the normal API mechanism for feeding in a dataset to + /// create an is to use the method. + /// + [BestFriend] + [Argument(ArgumentType.Required, HelpText = "Input dataset", Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly, SortOrder = 1)] + internal IDataView Data; + } +} diff --git a/src/Microsoft.ML.EntryPoints/FeatureCombiner.cs b/src/Microsoft.ML.EntryPoints/FeatureCombiner.cs index 39d47559fc..946fc0da55 100644 --- a/src/Microsoft.ML.EntryPoints/FeatureCombiner.cs +++ b/src/Microsoft.ML.EntryPoints/FeatureCombiner.cs @@ -12,6 +12,7 @@ using Microsoft.ML.Data; using Microsoft.ML.EntryPoints; using Microsoft.ML.Internal.Utilities; +using Microsoft.ML.Transforms; using Microsoft.ML.Transforms.Conversions; [assembly: LoadableClass(typeof(void), typeof(FeatureCombiner), null, typeof(SignatureEntryPointModule), "FeatureCombiner")] diff --git a/src/Microsoft.ML.EntryPoints/ModelOperations.cs b/src/Microsoft.ML.EntryPoints/ModelOperations.cs index ebd2a33fa7..8dc930f0b4 100644 --- a/src/Microsoft.ML.EntryPoints/ModelOperations.cs +++ b/src/Microsoft.ML.EntryPoints/ModelOperations.cs @@ -9,6 +9,7 @@ using Microsoft.ML.Data; using Microsoft.ML.EntryPoints; using Microsoft.ML.Trainers; +using Microsoft.ML.Transforms; [assembly: LoadableClass(typeof(void), typeof(ModelOperations), null, typeof(SignatureEntryPointModule), "ModelOperations")] diff --git a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs index 00d83fee24..2b3c9eb43e 100644 --- a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs +++ b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs @@ -9,6 +9,7 @@ using Microsoft.ML.CommandLine; using Microsoft.ML.Data; using Microsoft.ML.EntryPoints; +using Microsoft.ML.Trainers; using Microsoft.ML.Training; using Microsoft.ML.Transforms; using Newtonsoft.Json.Linq; diff --git a/src/Microsoft.ML.ImageAnalytics/ImageGrayscale.cs b/src/Microsoft.ML.ImageAnalytics/ImageGrayscale.cs index a4feb85ce8..7fd1810e2b 100644 --- a/src/Microsoft.ML.ImageAnalytics/ImageGrayscale.cs +++ b/src/Microsoft.ML.ImageAnalytics/ImageGrayscale.cs @@ -12,10 +12,10 @@ using Microsoft.ML; using Microsoft.ML.CommandLine; using Microsoft.ML.Data; -using Microsoft.ML.EntryPoints; using Microsoft.ML.ImageAnalytics; using Microsoft.ML.Internal.Utilities; using Microsoft.ML.Model; +using Microsoft.ML.Transforms; [assembly: LoadableClass(ImageGrayscalingTransformer.Summary, typeof(IDataTransform), typeof(ImageGrayscalingTransformer), typeof(ImageGrayscalingTransformer.Options), typeof(SignatureDataTransform), ImageGrayscalingTransformer.UserName, "ImageGrayscaleTransform", "ImageGrayscale")] diff --git a/src/Microsoft.ML.ImageAnalytics/ImageLoader.cs b/src/Microsoft.ML.ImageAnalytics/ImageLoader.cs index e5429ac8bf..cf2b19ed57 100644 --- a/src/Microsoft.ML.ImageAnalytics/ImageLoader.cs +++ b/src/Microsoft.ML.ImageAnalytics/ImageLoader.cs @@ -12,10 +12,10 @@ using Microsoft.ML; using Microsoft.ML.CommandLine; using Microsoft.ML.Data; -using Microsoft.ML.EntryPoints; using Microsoft.ML.ImageAnalytics; using Microsoft.ML.Internal.Utilities; using Microsoft.ML.Model; +using Microsoft.ML.Transforms; [assembly: LoadableClass(ImageLoadingTransformer.Summary, typeof(IDataTransform), typeof(ImageLoadingTransformer), typeof(ImageLoadingTransformer.Options), typeof(SignatureDataTransform), ImageLoadingTransformer.UserName, "ImageLoaderTransform", "ImageLoader")] diff --git a/src/Microsoft.ML.ImageAnalytics/ImagePixelExtractor.cs b/src/Microsoft.ML.ImageAnalytics/ImagePixelExtractor.cs index bc7b0c2359..9641d3493d 100644 --- a/src/Microsoft.ML.ImageAnalytics/ImagePixelExtractor.cs +++ b/src/Microsoft.ML.ImageAnalytics/ImagePixelExtractor.cs @@ -16,6 +16,7 @@ using Microsoft.ML.ImageAnalytics; using Microsoft.ML.Internal.Utilities; using Microsoft.ML.Model; +using Microsoft.ML.Transforms; [assembly: LoadableClass(ImagePixelExtractingTransformer.Summary, typeof(IDataTransform), typeof(ImagePixelExtractingTransformer), typeof(ImagePixelExtractingTransformer.Options), typeof(SignatureDataTransform), ImagePixelExtractingTransformer.UserName, "ImagePixelExtractorTransform", "ImagePixelExtractor")] diff --git a/src/Microsoft.ML.ImageAnalytics/ImageResizer.cs b/src/Microsoft.ML.ImageAnalytics/ImageResizer.cs index 9862678eb8..38b311b769 100644 --- a/src/Microsoft.ML.ImageAnalytics/ImageResizer.cs +++ b/src/Microsoft.ML.ImageAnalytics/ImageResizer.cs @@ -16,6 +16,7 @@ using Microsoft.ML.Internal.Internallearn; using Microsoft.ML.Internal.Utilities; using Microsoft.ML.Model; +using Microsoft.ML.Transforms; [assembly: LoadableClass(ImageResizingTransformer.Summary, typeof(IDataTransform), typeof(ImageResizingTransformer), typeof(ImageResizingTransformer.Arguments), typeof(SignatureDataTransform), ImageResizingTransformer.UserName, "ImageResizerTransform", "ImageResizer")] diff --git a/src/Microsoft.ML.ImageAnalytics/VectorToImageTransform.cs b/src/Microsoft.ML.ImageAnalytics/VectorToImageTransform.cs index c18c3c4811..2ad6ed9552 100644 --- a/src/Microsoft.ML.ImageAnalytics/VectorToImageTransform.cs +++ b/src/Microsoft.ML.ImageAnalytics/VectorToImageTransform.cs @@ -11,10 +11,10 @@ using Microsoft.ML; using Microsoft.ML.CommandLine; using Microsoft.ML.Data; -using Microsoft.ML.EntryPoints; using Microsoft.ML.ImageAnalytics; using Microsoft.ML.Internal.Utilities; using Microsoft.ML.Model; +using Microsoft.ML.Transforms; [assembly: LoadableClass(VectorToImageConvertingTransformer.Summary, typeof(IDataTransform), typeof(VectorToImageConvertingTransformer), typeof(VectorToImageConvertingTransformer.Options), typeof(SignatureDataTransform), ImagePixelExtractingTransformer.UserName, "VectorToImageTransform", "VectorToImage")] diff --git a/src/Microsoft.ML.LightGBM/LightGbmArguments.cs b/src/Microsoft.ML.LightGBM/LightGbmArguments.cs index a0fc2ba344..15a0626461 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmArguments.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmArguments.cs @@ -10,6 +10,7 @@ using Microsoft.ML.EntryPoints; using Microsoft.ML.Internal.Internallearn; using Microsoft.ML.LightGBM; +using Microsoft.ML.Trainers; [assembly: LoadableClass(typeof(Options.TreeBooster), typeof(Options.TreeBooster.Options), typeof(SignatureLightGBMBooster), Options.TreeBooster.FriendlyName, Options.TreeBooster.Name)] diff --git a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs index ee63841eb8..271aed0ffa 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs @@ -10,6 +10,7 @@ using Microsoft.ML.Internal.Calibration; using Microsoft.ML.LightGBM; using Microsoft.ML.Model; +using Microsoft.ML.Trainers; using Microsoft.ML.Trainers.FastTree; using Microsoft.ML.Training; diff --git a/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs index 49bb3166f5..94f5e6f0f6 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs @@ -9,6 +9,7 @@ using Microsoft.ML.EntryPoints; using Microsoft.ML.LightGBM; using Microsoft.ML.Model; +using Microsoft.ML.Trainers; using Microsoft.ML.Trainers.FastTree; using Microsoft.ML.Training; diff --git a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs index f431207956..5fbb2b528f 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs @@ -8,6 +8,7 @@ using Microsoft.ML.EntryPoints; using Microsoft.ML.LightGBM; using Microsoft.ML.Model; +using Microsoft.ML.Trainers; using Microsoft.ML.Trainers.FastTree; using Microsoft.ML.Training; diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs index aef265f8d7..eee2eb3940 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs @@ -13,6 +13,7 @@ using Microsoft.ML.FactorizationMachine; using Microsoft.ML.Internal.CpuMath; using Microsoft.ML.Internal.Utilities; +using Microsoft.ML.Trainers; using Microsoft.ML.Training; [assembly: LoadableClass(FieldAwareFactorizationMachineTrainer.Summary, typeof(FieldAwareFactorizationMachineTrainer), From c95796903012ef691c12eccaa71d659cd6e9ecbc Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Tue, 26 Feb 2019 14:28:11 -0800 Subject: [PATCH 02/11] fix build --- src/Microsoft.ML.Data/EntryPoints/InputBase.cs | 1 + src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs | 1 - .../FactorizationMachine/FactorizationMachineTrainer.cs | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs index 340795a967..1919847438 100644 --- a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs +++ b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs @@ -21,6 +21,7 @@ internal enum CachingOptions /// The base class for all evaluators inputs. /// [TlcModule.EntryPointKind(typeof(CommonInputs.IEvaluatorInput))] + [BestFriend] internal abstract class EvaluateInputBase { [Argument(ArgumentType.Required, ShortName = "data", HelpText = "The data to be used for evaluation.", SortOrder = 1, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] diff --git a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs index 2b3c9eb43e..716cc0b9fa 100644 --- a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs +++ b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs @@ -10,7 +10,6 @@ using Microsoft.ML.Data; using Microsoft.ML.EntryPoints; using Microsoft.ML.Trainers; -using Microsoft.ML.Training; using Microsoft.ML.Transforms; using Newtonsoft.Json.Linq; diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs index 5387700203..9d4040d94a 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs @@ -14,7 +14,6 @@ using Microsoft.ML.Internal.CpuMath; using Microsoft.ML.Internal.Utilities; using Microsoft.ML.Trainers; -using Microsoft.ML.Training; [assembly: LoadableClass(FieldAwareFactorizationMachineTrainer.Summary, typeof(FieldAwareFactorizationMachineTrainer), typeof(FieldAwareFactorizationMachineTrainer.Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer) } From 199f02be0e90e06efd3a584c528e819ae0362e5a Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Tue, 26 Feb 2019 15:07:55 -0800 Subject: [PATCH 03/11] Learner to Trainer --- src/Microsoft.ML.Data/Training/LearnerInputBase.cs | 14 +++++++------- src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs | 12 ++++++------ .../Trainer/EnsembleTrainerBase.cs | 2 +- src/Microsoft.ML.EntryPoints/ModelOperations.cs | 2 +- src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs | 2 +- src/Microsoft.ML.FastTree/FastTreeArguments.cs | 2 +- .../FastTreeClassification.cs | 8 ++++---- src/Microsoft.ML.FastTree/FastTreeRanking.cs | 8 ++++---- src/Microsoft.ML.FastTree/FastTreeRegression.cs | 8 ++++---- src/Microsoft.ML.FastTree/FastTreeTweedie.cs | 8 ++++---- src/Microsoft.ML.FastTree/GamTrainer.cs | 14 +++++++------- .../RandomForestClassification.cs | 8 ++++---- .../RandomForestRegression.cs | 8 ++++---- .../OlsLinearRegression.cs | 8 ++++---- .../SymSgdClassificationTrainer.cs | 6 +++--- .../KMeansPlusPlusTrainer.cs | 6 +++--- src/Microsoft.ML.LightGBM/LightGbmArguments.cs | 2 +- src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs | 6 +++--- .../LightGbmMulticlassTrainer.cs | 6 +++--- .../LightGbmRankingTrainer.cs | 8 ++++---- .../LightGbmRegressionTrainer.cs | 6 +++--- src/Microsoft.ML.PCA/PcaTrainer.cs | 6 +++--- .../FactorizationMachineTrainer.cs | 6 +++--- .../LogisticRegression/LbfgsPredictorBase.cs | 2 +- .../LogisticRegression/LogisticRegression.cs | 6 +++--- .../MulticlassLogisticRegression.cs | 6 +++--- .../MultiClass/MultiClassNaiveBayesTrainer.cs | 6 +++--- .../Standard/Online/AveragedPerceptron.cs | 4 ++-- .../Standard/Online/LinearSvm.cs | 4 ++-- .../Standard/Online/OnlineGradientDescent.cs | 4 ++-- .../Standard/Online/OnlineLinear.cs | 2 +- .../PoissonRegression/PoissonRegression.cs | 6 +++--- .../Standard/SdcaBinary.cs | 14 +++++++------- .../Standard/SdcaMultiClass.cs | 4 ++-- .../Standard/SdcaRegression.cs | 4 ++-- 35 files changed, 109 insertions(+), 109 deletions(-) diff --git a/src/Microsoft.ML.Data/Training/LearnerInputBase.cs b/src/Microsoft.ML.Data/Training/LearnerInputBase.cs index a929c0c8ed..ec8af64e21 100644 --- a/src/Microsoft.ML.Data/Training/LearnerInputBase.cs +++ b/src/Microsoft.ML.Data/Training/LearnerInputBase.cs @@ -17,7 +17,7 @@ namespace Microsoft.ML.Trainers /// The base class for all learner inputs. /// [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInput))] - public abstract class LearnerInputBase + public abstract class TrainerInputBase { /// /// The data to be used for training. Used only in entry-points, since in the API the expected mechanism is @@ -55,7 +55,7 @@ public abstract class LearnerInputBase /// The base class for all learner inputs that support a Label column. /// [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithLabel))] - public abstract class LearnerInputBaseWithLabel : LearnerInputBase + public abstract class TrainerInputBaseWithLabel : TrainerInputBase { /// /// Column to use for labels. @@ -69,7 +69,7 @@ public abstract class LearnerInputBaseWithLabel : LearnerInputBase /// The base class for all learner inputs that support a weight column. /// [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithWeight))] - public abstract class LearnerInputBaseWithWeight : LearnerInputBaseWithLabel + public abstract class TrainerInputBaseWithWeight : TrainerInputBaseWithLabel { /// /// Column to use for example weight. @@ -82,7 +82,7 @@ public abstract class LearnerInputBaseWithWeight : LearnerInputBaseWithLabel /// The base class for all unsupervised learner inputs that support a weight column. /// [TlcModule.EntryPointKind(typeof(CommonInputs.IUnsupervisedTrainerWithWeight))] - public abstract class UnsupervisedLearnerInputBaseWithWeight : LearnerInputBase + public abstract class UnsupervisedTrainerInputBaseWithWeight : TrainerInputBase { /// /// Column to use for example weight. @@ -92,7 +92,7 @@ public abstract class UnsupervisedLearnerInputBaseWithWeight : LearnerInputBase } [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithGroupId))] - public abstract class LearnerInputBaseWithGroupId : LearnerInputBaseWithWeight + public abstract class TrainerInputBaseWithGroupId : TrainerInputBaseWithWeight { /// /// Column to use for example groupId. @@ -102,7 +102,7 @@ public abstract class LearnerInputBaseWithGroupId : LearnerInputBaseWithWeight } [BestFriend] - internal static class LearnerEntryPointsUtils + internal static class TrainerEntryPointsUtils { public static string FindColumn(IExceptionContext ectx, DataViewSchema schema, Optional value) { @@ -130,7 +130,7 @@ public static TOut Train(IHost host, TArg input, Func>> getCustom = null, ICalibratorTrainerFactory calibrator = null, int maxCalibrationExamples = 0) - where TArg : LearnerInputBase + where TArg : TrainerInputBase where TOut : CommonOutputs.TrainerOutput, new() { using (var ch = host.Start("Training")) diff --git a/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs b/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs index afec3af471..c8f3cc8d6a 100644 --- a/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs +++ b/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs @@ -20,9 +20,9 @@ public static CommonOutputs.BinaryClassificationOutput CreateBinaryEnsemble(IHos host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new EnsembleTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } [TlcModule.EntryPoint(Name = "Trainers.EnsembleClassification", Desc = "Train multiclass ensemble.", UserName = EnsembleTrainer.UserNameValue)] @@ -33,9 +33,9 @@ public static CommonOutputs.MulticlassClassificationOutput CreateMultiClassEnsem host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new MulticlassDataPartitionEnsembleTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } [TlcModule.EntryPoint(Name = "Trainers.EnsembleRegression", Desc = "Train regression ensemble.", UserName = EnsembleTrainer.UserNameValue)] @@ -46,9 +46,9 @@ public static CommonOutputs.RegressionOutput CreateRegressionEnsemble(IHostEnvir host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new RegressionEnsembleTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } } } diff --git a/src/Microsoft.ML.Ensemble/Trainer/EnsembleTrainerBase.cs b/src/Microsoft.ML.Ensemble/Trainer/EnsembleTrainerBase.cs index 13e435e2e4..f650bb296e 100644 --- a/src/Microsoft.ML.Ensemble/Trainer/EnsembleTrainerBase.cs +++ b/src/Microsoft.ML.Ensemble/Trainer/EnsembleTrainerBase.cs @@ -22,7 +22,7 @@ internal abstract class EnsembleTrainerBase where TCombiner : class, IOutputCombiner { - public abstract class ArgumentsBase : LearnerInputBaseWithLabel + public abstract class ArgumentsBase : TrainerInputBaseWithLabel { #pragma warning disable CS0649 // These are set via reflection. [Argument(ArgumentType.AtMostOnce, diff --git a/src/Microsoft.ML.EntryPoints/ModelOperations.cs b/src/Microsoft.ML.EntryPoints/ModelOperations.cs index 8dc930f0b4..a639f3f3bb 100644 --- a/src/Microsoft.ML.EntryPoints/ModelOperations.cs +++ b/src/Microsoft.ML.EntryPoints/ModelOperations.cs @@ -53,7 +53,7 @@ public sealed class PredictorModelOutput public PredictorModel PredictorModel; } - public sealed class CombineOvaPredictorModelsInput : LearnerInputBaseWithWeight + public sealed class CombineOvaPredictorModelsInput : TrainerInputBaseWithWeight { [Argument(ArgumentType.Multiple, HelpText = "Input models", SortOrder = 1)] public PredictorModel[] ModelArray; diff --git a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs index 716cc0b9fa..a64edc3976 100644 --- a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs +++ b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs @@ -28,7 +28,7 @@ public sealed class SubGraphOutput public Var Model; } - public sealed class Arguments : LearnerInputBaseWithWeight + public sealed class Arguments : TrainerInputBaseWithWeight { // This is the subgraph that describes how to train a model for submodel. It should // accept one IDataView input and output one IPredictorModel output. diff --git a/src/Microsoft.ML.FastTree/FastTreeArguments.cs b/src/Microsoft.ML.FastTree/FastTreeArguments.cs index 11bb7a3e2c..be8ca0f0cc 100644 --- a/src/Microsoft.ML.FastTree/FastTreeArguments.cs +++ b/src/Microsoft.ML.FastTree/FastTreeArguments.cs @@ -150,7 +150,7 @@ internal static class Defaults public const double LearningRates = 0.2; } - public abstract class TreeOptions : LearnerInputBaseWithGroupId + public abstract class TreeOptions : TrainerInputBaseWithGroupId { /// /// Allows to choose Parallel FastTree Learning Algorithm. diff --git a/src/Microsoft.ML.FastTree/FastTreeClassification.cs b/src/Microsoft.ML.FastTree/FastTreeClassification.cs index cd33735d19..1f20e5b3de 100644 --- a/src/Microsoft.ML.FastTree/FastTreeClassification.cs +++ b/src/Microsoft.ML.FastTree/FastTreeClassification.cs @@ -412,11 +412,11 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeBinaryClassificationTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); } } } diff --git a/src/Microsoft.ML.FastTree/FastTreeRanking.cs b/src/Microsoft.ML.FastTree/FastTreeRanking.cs index bd76ab847f..c6372f28d4 100644 --- a/src/Microsoft.ML.FastTree/FastTreeRanking.cs +++ b/src/Microsoft.ML.FastTree/FastTreeRanking.cs @@ -1169,11 +1169,11 @@ public static CommonOutputs.RankingOutput TrainRanking(IHostEnvironment env, Fas host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeRankingTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); } } } diff --git a/src/Microsoft.ML.FastTree/FastTreeRegression.cs b/src/Microsoft.ML.FastTree/FastTreeRegression.cs index 5b3df90aa8..0e85fbc277 100644 --- a/src/Microsoft.ML.FastTree/FastTreeRegression.cs +++ b/src/Microsoft.ML.FastTree/FastTreeRegression.cs @@ -507,11 +507,11 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeRegressionTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); } } } diff --git a/src/Microsoft.ML.FastTree/FastTreeTweedie.cs b/src/Microsoft.ML.FastTree/FastTreeTweedie.cs index e87c54f34f..a65fa58e69 100644 --- a/src/Microsoft.ML.FastTree/FastTreeTweedie.cs +++ b/src/Microsoft.ML.FastTree/FastTreeTweedie.cs @@ -524,11 +524,11 @@ public static CommonOutputs.RegressionOutput TrainTweedieRegression(IHostEnviron host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeTweedieTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); } } } diff --git a/src/Microsoft.ML.FastTree/GamTrainer.cs b/src/Microsoft.ML.FastTree/GamTrainer.cs index fb081176b0..af2096456c 100644 --- a/src/Microsoft.ML.FastTree/GamTrainer.cs +++ b/src/Microsoft.ML.FastTree/GamTrainer.cs @@ -53,7 +53,7 @@ public abstract partial class GamTrainerBase where TOptions : GamTrainerBase.OptionsBase, new() where TPredictor : class { - public abstract class OptionsBase : LearnerInputBaseWithWeight + public abstract class OptionsBase : TrainerInputBaseWithWeight { [Argument(ArgumentType.LastOccurenceWins, HelpText = "The entropy (regularization) coefficient between 0 and 1", ShortName = "e")] public double EntropyCoefficient; @@ -680,10 +680,10 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new RegressionGamTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } [TlcModule.EntryPoint(Name = "Trainers.GeneralizedAdditiveModelBinaryClassifier", Desc = BinaryClassificationGamTrainer.Summary, UserName = BinaryClassificationGamTrainer.UserNameValue, ShortName = BinaryClassificationGamTrainer.ShortName)] @@ -694,10 +694,10 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new BinaryClassificationGamTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } diff --git a/src/Microsoft.ML.FastTree/RandomForestClassification.cs b/src/Microsoft.ML.FastTree/RandomForestClassification.cs index 894dc16239..a443658618 100644 --- a/src/Microsoft.ML.FastTree/RandomForestClassification.cs +++ b/src/Microsoft.ML.FastTree/RandomForestClassification.cs @@ -260,11 +260,11 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new FastForestClassification(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } diff --git a/src/Microsoft.ML.FastTree/RandomForestRegression.cs b/src/Microsoft.ML.FastTree/RandomForestRegression.cs index 7962f93810..4373f667d4 100644 --- a/src/Microsoft.ML.FastTree/RandomForestRegression.cs +++ b/src/Microsoft.ML.FastTree/RandomForestRegression.cs @@ -435,11 +435,11 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new FastForestRegression(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); } } } diff --git a/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs b/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs index 5cb947cad7..76f973cf9b 100644 --- a/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs +++ b/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs @@ -35,7 +35,7 @@ namespace Microsoft.ML.Trainers.HalLearners public sealed class OlsLinearRegressionTrainer : TrainerEstimatorBase, OlsLinearRegressionModelParameters> { /// Advanced options for trainer. - public sealed class Options : LearnerInputBaseWithWeight + public sealed class Options : TrainerInputBaseWithWeight { // Adding L2 regularization turns this into a form of ridge regression, // rather than, strictly speaking, ordinary least squares. But it is an @@ -499,10 +499,10 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment host.CheckValue(options, nameof(options)); EntryPointUtils.CheckInputArgs(host, options); - return LearnerEntryPointsUtils.Train(host, options, + return TrainerEntryPointsUtils.Train(host, options, () => new OlsLinearRegressionTrainer(host, options), - () => LearnerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.WeightColumn)); } } diff --git a/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs b/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs index 97829297a7..39cb355d60 100644 --- a/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs +++ b/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs @@ -38,7 +38,7 @@ public sealed class SymSgdClassificationTrainer : TrainerEstimatorBase Advanced options for trainer. - public sealed class Options : LearnerInputBaseWithLabel + public sealed class Options : TrainerInputBaseWithLabel { /// /// Degree of lock-free parallelism. Determinism not guaranteed if this is set to higher than 1. @@ -249,9 +249,9 @@ internal static CommonOutputs.BinaryClassificationOutput TrainSymSgd(IHostEnviro host.CheckValue(options, nameof(options)); EntryPointUtils.CheckInputArgs(host, options); - return LearnerEntryPointsUtils.Train(host, options, + return TrainerEntryPointsUtils.Train(host, options, () => new SymSgdClassificationTrainer(host, options), - () => LearnerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumn)); } // We buffer instances from the cursor (limited to memorySize) and passes that buffer to diff --git a/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs b/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs index 2d8d8b0bf1..f1db9a75db 100644 --- a/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs +++ b/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs @@ -50,7 +50,7 @@ internal static class Defaults public const int ClustersCount = 5; } - public sealed class Options : UnsupervisedLearnerInputBaseWithWeight + public sealed class Options : UnsupervisedTrainerInputBaseWithWeight { /// /// The number of clusters. @@ -248,9 +248,9 @@ internal static CommonOutputs.ClusteringOutput TrainKMeans(IHostEnvironment env, host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new KMeansPlusPlusTrainer(host, input), - getWeight: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } private protected override SchemaShape.Column[] GetOutputColumnsCore(SchemaShape inputSchema) diff --git a/src/Microsoft.ML.LightGBM/LightGbmArguments.cs b/src/Microsoft.ML.LightGBM/LightGbmArguments.cs index 15a0626461..0b635bfaed 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmArguments.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmArguments.cs @@ -41,7 +41,7 @@ public interface IBoosterParameter /// Parameters names comes from LightGBM library. /// See https://github.com/Microsoft/LightGBM/blob/master/docs/Parameters.rst. /// - public sealed class Options : LearnerInputBaseWithGroupId + public sealed class Options : TrainerInputBaseWithGroupId { public abstract class BoosterParameter : IBoosterParameter where TOptions : class, new() diff --git a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs index a778a00fd5..b46f6ea75c 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs @@ -190,10 +190,10 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmBinaryTrainer(host, input), - getLabel: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs index 8fdce0951f..71f7467019 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs @@ -246,10 +246,10 @@ public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHost host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmMulticlassTrainer(host, input), - getLabel: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs index ed6676a110..cea09fa3da 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs @@ -201,11 +201,11 @@ public static CommonOutputs.RankingOutput TrainRanking(IHostEnvironment env, Opt host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmRankingTrainer(host, input), - getLabel: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - getGroup: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + getGroup: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs index 304aee24b7..ae60ec6141 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs @@ -174,10 +174,10 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmRegressorTrainer(host, input), - getLabel: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } } diff --git a/src/Microsoft.ML.PCA/PcaTrainer.cs b/src/Microsoft.ML.PCA/PcaTrainer.cs index e4e506a61a..a511dc3c84 100644 --- a/src/Microsoft.ML.PCA/PcaTrainer.cs +++ b/src/Microsoft.ML.PCA/PcaTrainer.cs @@ -47,7 +47,7 @@ public sealed class RandomizedPcaTrainer : TrainerEstimatorBase(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new RandomizedPcaTrainer(host, input), - getWeight: () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs index 9d4040d94a..14329aa8b3 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs @@ -40,7 +40,7 @@ public sealed class FieldAwareFactorizationMachineTrainer : ITrainer(host, input, () => new FieldAwareFactorizationMachineTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + return TrainerEntryPointsUtils.Train(host, input, () => new FieldAwareFactorizationMachineTrainer(host, input), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } /// diff --git a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs index 42b0b78c5b..1e05fbeb67 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs @@ -20,7 +20,7 @@ public abstract class LbfgsTrainerBase : Trainer where TModel : class where TOptions : LbfgsTrainerBase.OptionsBase, new () { - public abstract class OptionsBase : LearnerInputBaseWithWeight + public abstract class OptionsBase : TrainerInputBaseWithWeight { [Argument(ArgumentType.AtMostOnce, HelpText = "L2 regularization weight", ShortName = "l2", SortOrder = 50)] [TGUI(Label = "L2 Weight", Description = "Weight of L2 regularizer term", SuggestedSweeps = "0,0.1,1")] diff --git a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs index 33efe385df..d12aa40725 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs @@ -419,10 +419,10 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LogisticRegression(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs index 7a40960a68..ec720980eb 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs @@ -1012,10 +1012,10 @@ internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHo host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new MulticlassLogisticRegression(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs index 41650b7c41..dfeb11ef9f 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs @@ -33,7 +33,7 @@ public sealed class MultiClassNaiveBayesTrainer : TrainerEstimatorBase(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new MultiClassNaiveBayesTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs index 0644cd07ad..f2948f7013 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs @@ -213,9 +213,9 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new AveragedPerceptronTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs index 9a597aa295..7e2e8c4b0d 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs @@ -285,9 +285,9 @@ internal static CommonOutputs.BinaryClassificationOutput TrainLinearSvm(IHostEnv host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LinearSvmTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs index f2db5449e5..709f3c046d 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs @@ -166,9 +166,9 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new OnlineGradientDescentTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } private protected override RegressionPredictionTransformer MakeTransformer(LinearRegressionModelParameters model, DataViewSchema trainSchema) diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs index c3c59b4793..7760da2023 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs @@ -19,7 +19,7 @@ namespace Microsoft.ML.Trainers.Online /// /// Arguments class for online linear trainers. /// - public abstract class OnlineLinearOptions : LearnerInputBaseWithLabel + public abstract class OnlineLinearOptions : TrainerInputBaseWithLabel { /// /// Number of passes through the training dataset. diff --git a/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs index 4ce4271521..ae181b78b6 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs @@ -182,10 +182,10 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new PoissonRegression(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); } } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs b/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs index 4476416c9f..ed40861f5d 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs @@ -156,7 +156,7 @@ public abstract class SdcaTrainerBase : Stochast // 3. Don't "guess" the iteration to converge. It is very data-set dependent and hard to control. Always check for at least once to ensure convergence. // 4. Use dual variable updates to infer whether a full iteration of convergence checking is necessary. Convergence checking iteration is time-consuming. - public abstract class OptionsBase : LearnerInputBaseWithLabel + public abstract class OptionsBase : TrainerInputBaseWithLabel { [Argument(ArgumentType.AtMostOnce, HelpText = "L2 regularizer constant. By default the l2 constant is automatically inferred based on data set.", NullName = "", ShortName = "l2", SortOrder = 1)] [TGUI(Label = "L2 Regularizer Constant", SuggestedSweeps = ",1e-7,1e-6,1e-5,1e-4,1e-3,1e-2")] @@ -1720,7 +1720,7 @@ public abstract class SgdBinaryTrainerBase : LinearTrainerBase, TModel> where TModel : class { - public class OptionsBase : LearnerInputBaseWithWeight + public class OptionsBase : TrainerInputBaseWithWeight { /// /// The L2 weight for regularization. @@ -2307,10 +2307,10 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LegacySgdBinaryTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } } @@ -2331,9 +2331,9 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new LegacySdcaBinaryTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs b/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs index 93ddbcce6f..39e418731c 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs @@ -453,9 +453,9 @@ public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHost host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new SdcaMultiClassTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } } } \ No newline at end of file diff --git a/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs index 2f72448b6f..29261964b5 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs @@ -176,9 +176,9 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, + return TrainerEntryPointsUtils.Train(host, input, () => new SdcaRegressionTrainer(host, input), - () => LearnerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } } } \ No newline at end of file From be5268620553b684be47e0b42910f9b5f7fe75d3 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Tue, 26 Feb 2019 15:09:33 -0800 Subject: [PATCH 04/11] Rename file --- .../Training/{LearnerInputBase.cs => TrainerInputBase.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Microsoft.ML.Data/Training/{LearnerInputBase.cs => TrainerInputBase.cs} (100%) diff --git a/src/Microsoft.ML.Data/Training/LearnerInputBase.cs b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs similarity index 100% rename from src/Microsoft.ML.Data/Training/LearnerInputBase.cs rename to src/Microsoft.ML.Data/Training/TrainerInputBase.cs From c2eebe151f59f2abc21e624c5e77a1b75637a747 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Tue, 26 Feb 2019 21:01:07 -0800 Subject: [PATCH 05/11] fix build --- src/Microsoft.ML.Data/Training/TrainerInputBase.cs | 2 +- .../FactorizationMachine/FactorizationMachineTrainer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs index ec8af64e21..d4d003b734 100644 --- a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs +++ b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs @@ -14,7 +14,7 @@ namespace Microsoft.ML.Trainers { /// - /// The base class for all learner inputs. + /// The base class for all trainer inputs. /// [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInput))] public abstract class TrainerInputBase diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs index 14329aa8b3..12e669910b 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs @@ -66,7 +66,7 @@ public sealed class Options : TrainerInputBaseWithWeight public bool Norm = true; /// - /// Extra feature column names. The column named stores features from the first field. + /// Extra feature column names. The column named stores features from the first field. /// The i-th string in stores the name of the (i+1)-th field's feature column. /// [Argument(ArgumentType.Multiple, HelpText = "Extra columns to use for feature vectors. The i-th specified string denotes the column containing features form the (i+1)-th field." + From 37bca1bf95fefd80bf93fb489c7c7981201cb5f0 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Tue, 26 Feb 2019 21:36:54 -0800 Subject: [PATCH 06/11] fix build --- src/Microsoft.ML.Data/Training/TrainerInputBase.cs | 2 +- .../FactorizationMachine/FactorizationMachineTrainer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs index d4d003b734..d41b4ed716 100644 --- a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs +++ b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs @@ -5,11 +5,11 @@ using System; using System.Collections.Generic; using Microsoft.Data.DataView; +using Microsoft.ML.Calibrators; using Microsoft.ML.CommandLine; using Microsoft.ML.Data; using Microsoft.ML.Data.IO; using Microsoft.ML.EntryPoints; -using Microsoft.ML.Internal.Calibration; namespace Microsoft.ML.Trainers { diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs index 8e9cfc0d1a..15b0d479bd 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs @@ -513,7 +513,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro var host = env.Register("Train a field-aware factorization machine"); host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return LearnerEntryPointsUtils.Train(host, input, () => new FieldAwareFactorizationMachineBinaryClassificationTrainer(host, input), + return TrainerEntryPointsUtils.Train(host, input, () => new FieldAwareFactorizationMachineBinaryClassificationTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); } From ed30b45a432a70b5ee624a118dc36515cd060c85 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Wed, 27 Feb 2019 10:00:26 -0800 Subject: [PATCH 07/11] fix commens --- .../EntryPoints/InputBase.cs | 99 +++++++++++++++++ .../Training/TrainerInputBase.cs | 104 ++---------------- .../Transforms/TransformInputBase.cs | 2 + 3 files changed, 111 insertions(+), 94 deletions(-) diff --git a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs index 1919847438..6bb8f0e77b 100644 --- a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs +++ b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs @@ -2,9 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; +using System.Collections.Generic; using Microsoft.Data.DataView; using Microsoft.ML.CommandLine; using Microsoft.ML.Data; +using Microsoft.ML.Data.IO; +using Microsoft.ML.Internal.Calibration; +using Microsoft.ML.Trainers; namespace Microsoft.ML.EntryPoints { @@ -31,6 +36,100 @@ internal abstract class EvaluateInputBase public string NameColumn = DefaultColumnNames.Name; } + [BestFriend] + internal static class TrainerEntryPointsUtils + { + public static string FindColumn(IExceptionContext ectx, DataViewSchema schema, Optional value) + { + Contracts.CheckValueOrNull(ectx); + ectx.CheckValue(schema, nameof(schema)); + ectx.CheckValue(value, nameof(value)); + + if (string.IsNullOrEmpty(value?.Value)) + return null; + if (!schema.TryGetColumnIndex(value, out int col)) + { + if (value.IsExplicit) + throw ectx.Except("Column '{0}' not found", value); + return null; + } + return value; + } + + public static TOut Train(IHost host, TArg input, + Func createTrainer, + Func getLabel = null, + Func getWeight = null, + Func getGroup = null, + Func getName = null, + Func>> getCustom = null, + ICalibratorTrainerFactory calibrator = null, + int maxCalibrationExamples = 0) + where TArg : TrainerInputBase + where TOut : CommonOutputs.TrainerOutput, new() + { + using (var ch = host.Start("Training")) + { + var schema = input.TrainingData.Schema; + var feature = FindColumn(ch, schema, input.FeatureColumn); + var label = getLabel?.Invoke(); + var weight = getWeight?.Invoke(); + var group = getGroup?.Invoke(); + var name = getName?.Invoke(); + var custom = getCustom?.Invoke(); + + var trainer = createTrainer(); + + IDataView view = input.TrainingData; + TrainUtils.AddNormalizerIfNeeded(host, ch, trainer, ref view, feature, input.NormalizeFeatures); + + ch.Trace("Binding columns"); + var roleMappedData = new RoleMappedData(view, label, feature, group, weight, name, custom); + + RoleMappedData cachedRoleMappedData = roleMappedData; + Cache.CachingType? cachingType = null; + switch (input.Caching) + { + case CachingOptions.Memory: + { + cachingType = Cache.CachingType.Memory; + break; + } + case CachingOptions.Disk: + { + cachingType = Cache.CachingType.Disk; + break; + } + case CachingOptions.Auto: + { + // REVIEW: we should switch to hybrid caching in future. + if (!(input.TrainingData is BinaryLoader) && trainer.Info.WantCaching) + // default to Memory so mml is on par with maml + cachingType = Cache.CachingType.Memory; + break; + } + case CachingOptions.None: + break; + default: + throw ch.ExceptParam(nameof(input.Caching), "Unknown option for caching: '{0}'", input.Caching); + } + + if (cachingType.HasValue) + { + var cacheView = Cache.CacheData(host, new Cache.CacheInput() + { + Data = roleMappedData.Data, + Caching = cachingType.Value + }).OutputData; + cachedRoleMappedData = new RoleMappedData(cacheView, roleMappedData.Schema.GetColumnRoleNames()); + } + + var predictor = TrainUtils.Train(host, ch, cachedRoleMappedData, trainer, calibrator, maxCalibrationExamples); + return new TOut() { PredictorModel = new PredictorModelImpl(host, roleMappedData, input.TrainingData, predictor) }; + } + } + } + /// /// Common input interfaces for TLC components. /// diff --git a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs index ec8af64e21..6fc050c29a 100644 --- a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs +++ b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs @@ -19,6 +19,8 @@ namespace Microsoft.ML.Trainers [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInput))] public abstract class TrainerInputBase { + private protected TrainerInputBase() { } + /// /// The data to be used for training. Used only in entry-points, since in the API the expected mechanism is /// that the user will use the or some other train @@ -57,6 +59,8 @@ public abstract class TrainerInputBase [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithLabel))] public abstract class TrainerInputBaseWithLabel : TrainerInputBase { + private protected TrainerInputBaseWithLabel() { } + /// /// Column to use for labels. /// @@ -71,6 +75,8 @@ public abstract class TrainerInputBaseWithLabel : TrainerInputBase [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithWeight))] public abstract class TrainerInputBaseWithWeight : TrainerInputBaseWithLabel { + private protected TrainerInputBaseWithWeight() { } + /// /// Column to use for example weight. /// @@ -84,6 +90,8 @@ public abstract class TrainerInputBaseWithWeight : TrainerInputBaseWithLabel [TlcModule.EntryPointKind(typeof(CommonInputs.IUnsupervisedTrainerWithWeight))] public abstract class UnsupervisedTrainerInputBaseWithWeight : TrainerInputBase { + private protected UnsupervisedTrainerInputBaseWithWeight() { } + /// /// Column to use for example weight. /// @@ -94,104 +102,12 @@ public abstract class UnsupervisedTrainerInputBaseWithWeight : TrainerInputBase [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithGroupId))] public abstract class TrainerInputBaseWithGroupId : TrainerInputBaseWithWeight { + private protected TrainerInputBaseWithGroupId() { } + /// /// Column to use for example groupId. /// [Argument(ArgumentType.AtMostOnce, Name = "GroupIdColumn", HelpText = "Column to use for example groupId", ShortName = "groupId", SortOrder = 5, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] public string GroupIdColumn = null; } - - [BestFriend] - internal static class TrainerEntryPointsUtils - { - public static string FindColumn(IExceptionContext ectx, DataViewSchema schema, Optional value) - { - Contracts.CheckValueOrNull(ectx); - ectx.CheckValue(schema, nameof(schema)); - ectx.CheckValue(value, nameof(value)); - - if (string.IsNullOrEmpty(value?.Value)) - return null; - if (!schema.TryGetColumnIndex(value, out int col)) - { - if (value.IsExplicit) - throw ectx.Except("Column '{0}' not found", value); - return null; - } - return value; - } - - public static TOut Train(IHost host, TArg input, - Func createTrainer, - Func getLabel = null, - Func getWeight = null, - Func getGroup = null, - Func getName = null, - Func>> getCustom = null, - ICalibratorTrainerFactory calibrator = null, - int maxCalibrationExamples = 0) - where TArg : TrainerInputBase - where TOut : CommonOutputs.TrainerOutput, new() - { - using (var ch = host.Start("Training")) - { - var schema = input.TrainingData.Schema; - var feature = FindColumn(ch, schema, input.FeatureColumn); - var label = getLabel?.Invoke(); - var weight = getWeight?.Invoke(); - var group = getGroup?.Invoke(); - var name = getName?.Invoke(); - var custom = getCustom?.Invoke(); - - var trainer = createTrainer(); - - IDataView view = input.TrainingData; - TrainUtils.AddNormalizerIfNeeded(host, ch, trainer, ref view, feature, input.NormalizeFeatures); - - ch.Trace("Binding columns"); - var roleMappedData = new RoleMappedData(view, label, feature, group, weight, name, custom); - - RoleMappedData cachedRoleMappedData = roleMappedData; - Cache.CachingType? cachingType = null; - switch (input.Caching) - { - case CachingOptions.Memory: - { - cachingType = Cache.CachingType.Memory; - break; - } - case CachingOptions.Disk: - { - cachingType = Cache.CachingType.Disk; - break; - } - case CachingOptions.Auto: - { - // REVIEW: we should switch to hybrid caching in future. - if (!(input.TrainingData is BinaryLoader) && trainer.Info.WantCaching) - // default to Memory so mml is on par with maml - cachingType = Cache.CachingType.Memory; - break; - } - case CachingOptions.None: - break; - default: - throw ch.ExceptParam(nameof(input.Caching), "Unknown option for caching: '{0}'", input.Caching); - } - - if (cachingType.HasValue) - { - var cacheView = Cache.CacheData(host, new Cache.CacheInput() - { - Data = roleMappedData.Data, - Caching = cachingType.Value - }).OutputData; - cachedRoleMappedData = new RoleMappedData(cacheView, roleMappedData.Schema.GetColumnRoleNames()); - } - - var predictor = TrainUtils.Train(host, ch, cachedRoleMappedData, trainer, calibrator, maxCalibrationExamples); - return new TOut() { PredictorModel = new PredictorModelImpl(host, roleMappedData, input.TrainingData, predictor) }; - } - } - } } diff --git a/src/Microsoft.ML.Data/Transforms/TransformInputBase.cs b/src/Microsoft.ML.Data/Transforms/TransformInputBase.cs index 174636092f..e123379824 100644 --- a/src/Microsoft.ML.Data/Transforms/TransformInputBase.cs +++ b/src/Microsoft.ML.Data/Transforms/TransformInputBase.cs @@ -14,6 +14,8 @@ namespace Microsoft.ML.Transforms [TlcModule.EntryPointKind(typeof(CommonInputs.ITransformInput))] public abstract class TransformInputBase { + private protected TransformInputBase() { } + /// /// The input dataset. Used only in entry-point methods, since the normal API mechanism for feeding in a dataset to /// create an is to use the method. From d457e901b7a26f175d88a69847cb8e752963f459 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Wed, 27 Feb 2019 10:28:07 -0800 Subject: [PATCH 08/11] fix #2760 --- ...ldAwareFactorizationMachinewWithOptions.cs | 4 +- .../SDCALogisticRegression.cs | 4 +- .../LightGbmWithOptions.cs | 4 +- .../Regression/LightGbmWithOptions.cs | 2 +- .../EntryPoints/EntryPointNode.cs | 6 +- .../EntryPoints/InputBase.cs | 3 +- .../Training/TrainerInputBase.cs | 12 +- .../EntryPoints/Ensemble.cs | 6 +- .../MulticlassDataPartitionEnsembleTrainer.cs | 2 +- .../ModelOperations.cs | 12 +- .../OneVersusAllMacro.cs | 16 +-- .../TrainTestMacro.cs | 2 +- src/Microsoft.ML.FastTree/FastTree.cs | 12 +- .../FastTreeClassification.cs | 8 +- src/Microsoft.ML.FastTree/FastTreeRanking.cs | 8 +- .../FastTreeRegression.cs | 8 +- src/Microsoft.ML.FastTree/FastTreeTweedie.cs | 8 +- .../GamClassification.cs | 2 +- src/Microsoft.ML.FastTree/GamRegression.cs | 2 +- src/Microsoft.ML.FastTree/GamTrainer.cs | 18 +-- .../RandomForestClassification.cs | 8 +- .../RandomForestRegression.cs | 8 +- .../HalLearnersCatalog.cs | 10 +- .../OlsLinearRegression.cs | 8 +- .../SymSgdClassificationTrainer.cs | 6 +- .../KMeansCatalog.cs | 4 +- .../KMeansPlusPlusTrainer.cs | 6 +- .../LightGbmStaticExtensions.cs | 26 ++--- .../LightGbmBinaryTrainer.cs | 6 +- .../LightGbmMulticlassTrainer.cs | 6 +- .../LightGbmRankingTrainer.cs | 8 +- .../LightGbmRegressionTrainer.cs | 6 +- .../LightGbmTrainerBase.cs | 12 +- src/Microsoft.ML.PCA/PcaTrainer.cs | 4 +- .../FactorizationMachineTrainer.cs | 12 +- .../LogisticRegression/LbfgsPredictorBase.cs | 24 ++-- .../LogisticRegression/LogisticRegression.cs | 6 +- .../MulticlassLogisticRegression.cs | 6 +- .../Standard/ModelStatistics.cs | 2 +- .../MultiClass/MultiClassNaiveBayesTrainer.cs | 6 +- .../Standard/Online/AveragedPerceptron.cs | 8 +- .../Standard/Online/LinearSvm.cs | 8 +- .../Standard/Online/OnlineGradientDescent.cs | 8 +- .../Standard/Online/OnlineLinear.cs | 2 +- .../PoissonRegression/PoissonRegression.cs | 6 +- .../Standard/SdcaBinary.cs | 22 ++-- .../Standard/SdcaMultiClass.cs | 4 +- .../Standard/SdcaRegression.cs | 4 +- src/Microsoft.ML.StaticPipe/KMeansStatic.cs | 8 +- src/Microsoft.ML.StaticPipe/LbfgsStatic.cs | 18 +-- .../OnlineLearnerStatic.cs | 8 +- .../SdcaStaticExtensions.cs | 16 +-- src/Microsoft.ML.StaticPipe/SgdStatic.cs | 12 +- .../TreeTrainersStatic.cs | 20 ++-- .../Algorithms/SmacSweeper.cs | 4 +- .../UnitTests/TestEntryPoints.cs | 106 +++++++++--------- .../Prediction.cs | 2 +- .../TestPredictors.cs | 36 +++--- test/Microsoft.ML.Tests/OnnxConversionTest.cs | 2 +- .../TensorflowTests.cs | 4 +- .../TrainerEstimators/FAFMEstimator.cs | 4 +- .../TrainerEstimators/MetalinearEstimators.cs | 4 +- .../TrainerEstimators/TrainerEstimators.cs | 4 +- .../TrainerEstimators/TreeEstimators.cs | 6 +- 64 files changed, 314 insertions(+), 315 deletions(-) diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs index c93b735a59..7290efe9d0 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs @@ -32,8 +32,8 @@ public static void Example() FieldAwareFactorizationMachine( new FieldAwareFactorizationMachineBinaryClassificationTrainer.Options { - FeatureColumn = "Features", - LabelColumn = "Sentiment", + FeatureColumnName = "Features", + LabelColumnName = "Sentiment", LearningRate = 0.1f, NumberOfIterations = 10 })); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SDCALogisticRegression.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SDCALogisticRegression.cs index db34ef01db..edae61a813 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SDCALogisticRegression.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SDCALogisticRegression.cs @@ -62,8 +62,8 @@ public static void Example() var advancedPipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features") .Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent( new SdcaBinaryTrainer.Options { - LabelColumn = "Sentiment", - FeatureColumn = "Features", + LabelColumnName = "Sentiment", + FeatureColumnName = "Features", ConvergenceTolerance = 0.01f, // The learning rate for adjusting bias from being regularized NumThreads = 2, // Degree of lock-free parallelism })); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/LightGbmWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/LightGbmWithOptions.cs index 8015890e71..03829ed605 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/LightGbmWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/LightGbmWithOptions.cs @@ -35,8 +35,8 @@ public static void Example() var pipeline = mlContext.Transforms.Conversion.MapValueToKey("LabelIndex", "Label") .Append(mlContext.MulticlassClassification.Trainers.LightGbm(new Options { - LabelColumn = "LabelIndex", - FeatureColumn = "Features", + LabelColumnName = "LabelIndex", + FeatureColumnName = "Features", Booster = new DartBooster.Options { DropRate = 0.15, diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/LightGbmWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/LightGbmWithOptions.cs index c1c82a9735..e93eeb3f96 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/LightGbmWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/LightGbmWithOptions.cs @@ -38,7 +38,7 @@ public static void Example() var pipeline = mlContext.Transforms.Concatenate("Features", featureNames) .Append(mlContext.Regression.Trainers.LightGbm(new Options { - LabelColumn = labelName, + LabelColumnName = labelName, NumLeaves = 4, MinDataPerLeaf = 6, LearningRate = 0.001, diff --git a/src/Microsoft.ML.Data/EntryPoints/EntryPointNode.cs b/src/Microsoft.ML.Data/EntryPoints/EntryPointNode.cs index f294bb3452..fac0d77753 100644 --- a/src/Microsoft.ML.Data/EntryPoints/EntryPointNode.cs +++ b/src/Microsoft.ML.Data/EntryPoints/EntryPointNode.cs @@ -509,9 +509,9 @@ private EntryPointNode(IHostEnvironment env, IChannel ch, RunContext context, throw _host.Except($"The following required inputs were not provided: {String.Join(", ", missing)}"); var inputInstance = _inputBuilder.GetInstance(); - SetColumnArgument(ch, inputInstance, "LabelColumn", label, "label", typeof(CommonInputs.ITrainerInputWithLabel)); - SetColumnArgument(ch, inputInstance, "GroupIdColumn", group, "group Id", typeof(CommonInputs.ITrainerInputWithGroupId)); - SetColumnArgument(ch, inputInstance, "WeightColumn", weight, "weight", typeof(CommonInputs.ITrainerInputWithWeight), typeof(CommonInputs.IUnsupervisedTrainerWithWeight)); + SetColumnArgument(ch, inputInstance, "LabelColumnName", label, "label", typeof(CommonInputs.ITrainerInputWithLabel)); + SetColumnArgument(ch, inputInstance, "RowGroupColumnName", group, "group Id", typeof(CommonInputs.ITrainerInputWithGroupId)); + SetColumnArgument(ch, inputInstance, "ExampleWeightColumnName", weight, "weight", typeof(CommonInputs.ITrainerInputWithWeight), typeof(CommonInputs.IUnsupervisedTrainerWithWeight)); SetColumnArgument(ch, inputInstance, "NameColumn", name, "name"); // Validate outputs. diff --git a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs index c70cf4ef04..d228fe836d 100644 --- a/src/Microsoft.ML.Data/EntryPoints/InputBase.cs +++ b/src/Microsoft.ML.Data/EntryPoints/InputBase.cs @@ -9,7 +9,6 @@ using Microsoft.ML.CommandLine; using Microsoft.ML.Data; using Microsoft.ML.Data.IO; -using Microsoft.ML.Internal.Calibration; using Microsoft.ML.Trainers; namespace Microsoft.ML.EntryPoints @@ -72,7 +71,7 @@ public static TOut Train(IHost host, TArg input, using (var ch = host.Start("Training")) { var schema = input.TrainingData.Schema; - var feature = FindColumn(ch, schema, input.FeatureColumn); + var feature = FindColumn(ch, schema, input.FeatureColumnName); var label = getLabel?.Invoke(); var weight = getWeight?.Invoke(); var group = getGroup?.Invoke(); diff --git a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs index 6fdceecad1..1387c27220 100644 --- a/src/Microsoft.ML.Data/Training/TrainerInputBase.cs +++ b/src/Microsoft.ML.Data/Training/TrainerInputBase.cs @@ -34,7 +34,7 @@ private protected TrainerInputBase() { } /// Column to use for features. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for features", ShortName = "feat", SortOrder = 2, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string FeatureColumn = DefaultColumnNames.Features; + public string FeatureColumnName = DefaultColumnNames.Features; /// /// Normalize option for the feature column. Used only in entry-points, since in the API the user is expected to do this themselves. @@ -65,7 +65,7 @@ private protected TrainerInputBaseWithLabel() { } /// Column to use for labels. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for labels", ShortName = "lab", SortOrder = 3, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string LabelColumn = DefaultColumnNames.Label; + public string LabelColumnName = DefaultColumnNames.Label; } // REVIEW: This is a known antipattern, but the solution involves the decorator pattern which can't be used in this case. @@ -81,7 +81,7 @@ private protected TrainerInputBaseWithWeight() { } /// Column to use for example weight. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string WeightColumn = null; + public string ExampleWeightColumnName = null; } /// @@ -96,7 +96,7 @@ private protected UnsupervisedTrainerInputBaseWithWeight() { } /// Column to use for example weight. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string WeightColumn = null; + public string ExampleWeightColumnName = null; } [TlcModule.EntryPointKind(typeof(CommonInputs.ITrainerInputWithGroupId))] @@ -107,7 +107,7 @@ private protected TrainerInputBaseWithGroupId() { } /// /// Column to use for example groupId. /// - [Argument(ArgumentType.AtMostOnce, Name = "GroupIdColumn", HelpText = "Column to use for example groupId", ShortName = "groupId", SortOrder = 5, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] - public string GroupIdColumn = null; + [Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example groupId", ShortName = "groupId", SortOrder = 5, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)] + public string RowGroupColumnName = null; } } diff --git a/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs b/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs index c8f3cc8d6a..fab5ecfe2c 100644 --- a/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs +++ b/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs @@ -22,7 +22,7 @@ public static CommonOutputs.BinaryClassificationOutput CreateBinaryEnsemble(IHos return TrainerEntryPointsUtils.Train(host, input, () => new EnsembleTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } [TlcModule.EntryPoint(Name = "Trainers.EnsembleClassification", Desc = "Train multiclass ensemble.", UserName = EnsembleTrainer.UserNameValue)] @@ -35,7 +35,7 @@ public static CommonOutputs.MulticlassClassificationOutput CreateMultiClassEnsem return TrainerEntryPointsUtils.Train(host, input, () => new MulticlassDataPartitionEnsembleTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } [TlcModule.EntryPoint(Name = "Trainers.EnsembleRegression", Desc = "Train regression ensemble.", UserName = EnsembleTrainer.UserNameValue)] @@ -48,7 +48,7 @@ public static CommonOutputs.RegressionOutput CreateRegressionEnsemble(IHostEnvir return TrainerEntryPointsUtils.Train(host, input, () => new RegressionEnsembleTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } } } diff --git a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs index a5f0c93604..3d44c3d30f 100644 --- a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs +++ b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs @@ -63,7 +63,7 @@ public Arguments() // non-default column names. Unfortuantely no method of resolving this temporary strikes me as being any // less laborious than the proper fix, which is that this "meta" component should itself be a trainer // estimator, as opposed to a regular trainer. - var trainerEstimator = new MulticlassLogisticRegression(env, LabelColumn, FeatureColumn); + var trainerEstimator = new MulticlassLogisticRegression(env, LabelColumnName, FeatureColumnName); return TrainerUtils.MapTrainerEstimatorToTrainer(env, trainerEstimator); }) diff --git a/src/Microsoft.ML.EntryPoints/ModelOperations.cs b/src/Microsoft.ML.EntryPoints/ModelOperations.cs index a639f3f3bb..41ba5d93ca 100644 --- a/src/Microsoft.ML.EntryPoints/ModelOperations.cs +++ b/src/Microsoft.ML.EntryPoints/ModelOperations.cs @@ -143,13 +143,13 @@ public static PredictorModelOutput CombineOvaModels(IHostEnvironment env, Combin using (var ch = host.Start("CombineOvaModels")) { var schema = normalizedView.Schema; - var label = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(input.LabelColumn), - input.LabelColumn, + var label = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(input.LabelColumnName), + input.LabelColumnName, DefaultColumnNames.Label); - var feature = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(input.FeatureColumn), - input.FeatureColumn, DefaultColumnNames.Features); - var weight = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(input.WeightColumn), - input.WeightColumn, DefaultColumnNames.Weight); + var feature = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(input.FeatureColumnName), + input.FeatureColumnName, DefaultColumnNames.Features); + var weight = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(input.ExampleWeightColumnName), + input.ExampleWeightColumnName, DefaultColumnNames.Weight); var data = new RoleMappedData(normalizedView, label, feature, null, weight); return new PredictorModelOutput diff --git a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs index a64edc3976..4fb062cced 100644 --- a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs +++ b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs @@ -119,13 +119,13 @@ private static int GetNumberOfClasses(IHostEnvironment env, Arguments input, out { // RoleMappedData creation var schema = input.TrainingData.Schema; - label = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.LabelColumn), - input.LabelColumn, + label = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.LabelColumnName), + input.LabelColumnName, DefaultColumnNames.Label); - var feature = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.FeatureColumn), - input.FeatureColumn, DefaultColumnNames.Features); - var weight = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.WeightColumn), - input.WeightColumn, DefaultColumnNames.Weight); + var feature = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.FeatureColumnName), + input.FeatureColumnName, DefaultColumnNames.Features); + var weight = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.ExampleWeightColumnName), + input.ExampleWeightColumnName, DefaultColumnNames.Weight); // Get number of classes var data = new RoleMappedData(input.TrainingData, label, feature, null, weight); @@ -164,8 +164,8 @@ public static CommonOutputs.MacroOutput OneVersusAll( // produces single multiclass predictor model. var combineArgs = new ModelOperations.CombineOvaPredictorModelsInput(); combineArgs.Caching = input.Caching; - combineArgs.FeatureColumn = input.FeatureColumn; - combineArgs.LabelColumn = input.LabelColumn; + combineArgs.FeatureColumnName = input.FeatureColumnName; + combineArgs.LabelColumnName = input.LabelColumnName; combineArgs.NormalizeFeatures = input.NormalizeFeatures; combineArgs.UseProbabilities = input.UseProbabilities; diff --git a/src/Microsoft.ML.EntryPoints/TrainTestMacro.cs b/src/Microsoft.ML.EntryPoints/TrainTestMacro.cs index cba12df109..f95eb19dc3 100644 --- a/src/Microsoft.ML.EntryPoints/TrainTestMacro.cs +++ b/src/Microsoft.ML.EntryPoints/TrainTestMacro.cs @@ -209,7 +209,7 @@ public static CommonOutputs.MacroOutput TrainTest( subGraphNodes.Add(scoreNode); var evalDataVarName = scoreNodeOutputScoredData.VarName; - // REVIEW: add similar support for FeatureColumn. + // REVIEW: add similar support for FeatureColumnName. var settings = new MacroUtils.EvaluatorSettings { LabelColumn = input.LabelColumn, diff --git a/src/Microsoft.ML.FastTree/FastTree.cs b/src/Microsoft.ML.FastTree/FastTree.cs index 240cf6d2cd..99abd7f419 100644 --- a/src/Microsoft.ML.FastTree/FastTree.cs +++ b/src/Microsoft.ML.FastTree/FastTree.cs @@ -119,10 +119,10 @@ private protected FastTreeTrainerBase(IHostEnvironment env, FastTreeTrainerOptions.NumTrees = numTrees; FastTreeTrainerOptions.MinDocumentsInLeafs = minDatapointsInLeaves; - FastTreeTrainerOptions.LabelColumn = label.Name; - FastTreeTrainerOptions.FeatureColumn = featureColumn; - FastTreeTrainerOptions.WeightColumn = weightColumn; - FastTreeTrainerOptions.GroupIdColumn = groupIdColumn; + FastTreeTrainerOptions.LabelColumnName = label.Name; + FastTreeTrainerOptions.FeatureColumnName = featureColumn; + FastTreeTrainerOptions.ExampleWeightColumnName = weightColumn; + FastTreeTrainerOptions.RowGroupColumnName = groupIdColumn; // The discretization step renders this trainer non-parametric, and therefore it does not need normalization. // Also since it builds its own internal discretized columnar structures, it cannot benefit from caching. @@ -141,8 +141,8 @@ private protected FastTreeTrainerBase(IHostEnvironment env, /// Constructor that is used when invoking the classes deriving from this, through maml. /// private protected FastTreeTrainerBase(IHostEnvironment env, TOptions options, SchemaShape.Column label) - : base(Contracts.CheckRef(env, nameof(env)).Register(RegisterName), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), label, TrainerUtils.MakeR4ScalarWeightColumn(options.WeightColumn), - TrainerUtils.MakeU4ScalarColumn(options.GroupIdColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(RegisterName), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), label, TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName), + TrainerUtils.MakeU4ScalarColumn(options.RowGroupColumnName)) { Host.CheckValue(options, nameof(options)); FastTreeTrainerOptions = options; diff --git a/src/Microsoft.ML.FastTree/FastTreeClassification.cs b/src/Microsoft.ML.FastTree/FastTreeClassification.cs index 94040a1ff4..51b406f50e 100644 --- a/src/Microsoft.ML.FastTree/FastTreeClassification.cs +++ b/src/Microsoft.ML.FastTree/FastTreeClassification.cs @@ -146,7 +146,7 @@ internal FastTreeBinaryClassificationTrainer(IHostEnvironment env, /// The instance of . /// Algorithm advanced settings. internal FastTreeBinaryClassificationTrainer(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { // Set the sigmoid parameter to the 2 * learning rate, for traditional FastTreeClassification loss _sigmoidParameter = 2.0 * FastTreeTrainerOptions.LearningRates; @@ -413,9 +413,9 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeBinaryClassificationTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName)); } } } diff --git a/src/Microsoft.ML.FastTree/FastTreeRanking.cs b/src/Microsoft.ML.FastTree/FastTreeRanking.cs index c6372f28d4..88e5c41485 100644 --- a/src/Microsoft.ML.FastTree/FastTreeRanking.cs +++ b/src/Microsoft.ML.FastTree/FastTreeRanking.cs @@ -89,7 +89,7 @@ internal FastTreeRankingTrainer(IHostEnvironment env, /// The instance of . /// Algorithm advanced settings. internal FastTreeRankingTrainer(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } @@ -1171,9 +1171,9 @@ public static CommonOutputs.RankingOutput TrainRanking(IHostEnvironment env, Fas return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeRankingTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName)); } } } diff --git a/src/Microsoft.ML.FastTree/FastTreeRegression.cs b/src/Microsoft.ML.FastTree/FastTreeRegression.cs index 0e85fbc277..3533adfd6a 100644 --- a/src/Microsoft.ML.FastTree/FastTreeRegression.cs +++ b/src/Microsoft.ML.FastTree/FastTreeRegression.cs @@ -77,7 +77,7 @@ internal FastTreeRegressionTrainer(IHostEnvironment env, /// The instance of . /// Algorithm advanced settings. internal FastTreeRegressionTrainer(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } @@ -509,9 +509,9 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeRegressionTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName)); } } } diff --git a/src/Microsoft.ML.FastTree/FastTreeTweedie.cs b/src/Microsoft.ML.FastTree/FastTreeTweedie.cs index a65fa58e69..b18ed335f3 100644 --- a/src/Microsoft.ML.FastTree/FastTreeTweedie.cs +++ b/src/Microsoft.ML.FastTree/FastTreeTweedie.cs @@ -79,7 +79,7 @@ internal FastTreeTweedieTrainer(IHostEnvironment env, /// The instance of . /// Algorithm advanced settings. internal FastTreeTweedieTrainer(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { Initialize(); } @@ -526,9 +526,9 @@ public static CommonOutputs.RegressionOutput TrainTweedieRegression(IHostEnviron return TrainerEntryPointsUtils.Train(host, input, () => new FastTreeTweedieTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName)); } } } diff --git a/src/Microsoft.ML.FastTree/GamClassification.cs b/src/Microsoft.ML.FastTree/GamClassification.cs index 6d2b110a97..ba75b315d6 100644 --- a/src/Microsoft.ML.FastTree/GamClassification.cs +++ b/src/Microsoft.ML.FastTree/GamClassification.cs @@ -50,7 +50,7 @@ public sealed class Options : OptionsBase /// Initializes a new instance of /// internal BinaryClassificationGamTrainer(IHostEnvironment env, Options options) - : base(env, options, LoadNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(env, options, LoadNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { _sigmoidParameter = 1; } diff --git a/src/Microsoft.ML.FastTree/GamRegression.cs b/src/Microsoft.ML.FastTree/GamRegression.cs index 74a9481e11..fc27185c02 100644 --- a/src/Microsoft.ML.FastTree/GamRegression.cs +++ b/src/Microsoft.ML.FastTree/GamRegression.cs @@ -39,7 +39,7 @@ public partial class Options : OptionsBase private protected override PredictionKind PredictionKind => PredictionKind.Regression; internal RegressionGamTrainer(IHostEnvironment env, Options options) - : base(env, options, LoadNameValue, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) { } + : base(env, options, LoadNameValue, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } /// /// Initializes a new instance of diff --git a/src/Microsoft.ML.FastTree/GamTrainer.cs b/src/Microsoft.ML.FastTree/GamTrainer.cs index af2096456c..214a661000 100644 --- a/src/Microsoft.ML.FastTree/GamTrainer.cs +++ b/src/Microsoft.ML.FastTree/GamTrainer.cs @@ -160,11 +160,11 @@ private protected GamTrainerBase(IHostEnvironment env, GamTrainerOptions.LearningRates = learningRate; GamTrainerOptions.MaxBins = maxBins; - GamTrainerOptions.LabelColumn = label.Name; - GamTrainerOptions.FeatureColumn = featureColumn; + GamTrainerOptions.LabelColumnName = label.Name; + GamTrainerOptions.FeatureColumnName = featureColumn; if (weightColumn != null) - GamTrainerOptions.WeightColumn = weightColumn; + GamTrainerOptions.ExampleWeightColumnName = weightColumn; Info = new TrainerInfo(normalization: false, calibration: NeedCalibration, caching: false, supportValid: true); _gainConfidenceInSquaredStandardDeviations = Math.Pow(ProbabilityFunctions.Probit(1 - (1 - GamTrainerOptions.GainConfidenceLevel) * 0.5), 2); @@ -174,8 +174,8 @@ private protected GamTrainerBase(IHostEnvironment env, } private protected GamTrainerBase(IHostEnvironment env, TOptions options, string name, SchemaShape.Column label) - : base(Contracts.CheckRef(env, nameof(env)).Register(name), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), - label, TrainerUtils.MakeR4ScalarWeightColumn(options.WeightColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(name), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), + label, TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName)) { Contracts.CheckValue(env, nameof(env)); Host.CheckValue(options, nameof(options)); @@ -682,8 +682,8 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en return TrainerEntryPointsUtils.Train(host, input, () => new RegressionGamTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } [TlcModule.EntryPoint(Name = "Trainers.GeneralizedAdditiveModelBinaryClassifier", Desc = BinaryClassificationGamTrainer.Summary, UserName = BinaryClassificationGamTrainer.UserNameValue, ShortName = BinaryClassificationGamTrainer.ShortName)] @@ -696,8 +696,8 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm return TrainerEntryPointsUtils.Train(host, input, () => new BinaryClassificationGamTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } diff --git a/src/Microsoft.ML.FastTree/RandomForestClassification.cs b/src/Microsoft.ML.FastTree/RandomForestClassification.cs index 0fb840f434..60fc2e6242 100644 --- a/src/Microsoft.ML.FastTree/RandomForestClassification.cs +++ b/src/Microsoft.ML.FastTree/RandomForestClassification.cs @@ -160,7 +160,7 @@ internal FastForestClassification(IHostEnvironment env, /// The instance of . /// Algorithm advanced settings. internal FastForestClassification(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { } @@ -261,9 +261,9 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm return TrainerEntryPointsUtils.Train(host, input, () => new FastForestClassification(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } diff --git a/src/Microsoft.ML.FastTree/RandomForestRegression.cs b/src/Microsoft.ML.FastTree/RandomForestRegression.cs index 4373f667d4..359217da05 100644 --- a/src/Microsoft.ML.FastTree/RandomForestRegression.cs +++ b/src/Microsoft.ML.FastTree/RandomForestRegression.cs @@ -289,7 +289,7 @@ internal FastForestRegression(IHostEnvironment env, /// The instance of . /// Algorithm advanced settings. internal FastForestRegression(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn), true) + : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName), true) { } @@ -437,9 +437,9 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en return TrainerEntryPointsUtils.Train(host, input, () => new FastForestRegression(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName)); } } } diff --git a/src/Microsoft.ML.HalLearners/HalLearnersCatalog.cs b/src/Microsoft.ML.HalLearners/HalLearnersCatalog.cs index b92b8cfb8e..35068f4fe1 100644 --- a/src/Microsoft.ML.HalLearners/HalLearnersCatalog.cs +++ b/src/Microsoft.ML.HalLearners/HalLearnersCatalog.cs @@ -37,9 +37,9 @@ public static OlsLinearRegressionTrainer OrdinaryLeastSquares(this RegressionCat var env = CatalogUtils.GetEnvironment(catalog); var options = new OlsLinearRegressionTrainer.Options { - LabelColumn = labelColumnName, - FeatureColumn = featureColumnName, - WeightColumn = exampleWeightColumnName + LabelColumnName = labelColumnName, + FeatureColumnName = featureColumnName, + ExampleWeightColumnName = exampleWeightColumnName }; return new OlsLinearRegressionTrainer(env, options); @@ -92,8 +92,8 @@ public static SymSgdClassificationTrainer SymbolicStochasticGradientDescent(this var options = new SymSgdClassificationTrainer.Options { - LabelColumn = labelColumnName, - FeatureColumn = featureColumnName, + LabelColumnName = labelColumnName, + FeatureColumnName = featureColumnName, }; return new SymSgdClassificationTrainer(env, options); diff --git a/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs b/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs index 76f973cf9b..8204ac87d7 100644 --- a/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs +++ b/src/Microsoft.ML.HalLearners/OlsLinearRegression.cs @@ -76,8 +76,8 @@ public sealed class Options : TrainerInputBaseWithWeight /// Initializes a new instance of /// internal OlsLinearRegressionTrainer(IHostEnvironment env, Options options) - : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), - TrainerUtils.MakeR4ScalarColumn(options.LabelColumn), TrainerUtils.MakeR4ScalarWeightColumn(options.WeightColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), + TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName), TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName)) { Host.CheckValue(options, nameof(options)); Host.CheckUserArg(options.L2Weight >= 0, nameof(options.L2Weight), "L2 regularization term cannot be negative"); @@ -501,8 +501,8 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment return TrainerEntryPointsUtils.Train(host, options, () => new OlsLinearRegressionTrainer(host, options), - () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.ExampleWeightColumnName)); } } diff --git a/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs b/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs index b299ae6346..14da40b3a9 100644 --- a/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs +++ b/src/Microsoft.ML.HalLearners/SymSgdClassificationTrainer.cs @@ -198,8 +198,8 @@ private protected override TPredictor TrainModelCore(TrainContext context) /// Initializes a new instance of /// internal SymSgdClassificationTrainer(IHostEnvironment env, Options options) - : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), - TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), + TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { Host.CheckValue(options, nameof(options)); options.Check(Host); @@ -252,7 +252,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainSymSgd(IHostEnviro return TrainerEntryPointsUtils.Train(host, options, () => new SymSgdClassificationTrainer(host, options), - () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumnName)); } // We buffer instances from the cursor (limited to memorySize) and passes that buffer to diff --git a/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs b/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs index f7c4067861..6fae15fe8c 100644 --- a/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs +++ b/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs @@ -37,8 +37,8 @@ public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrai var options = new KMeansPlusPlusTrainer.Options { - FeatureColumn = featureColumnName, - WeightColumn = exampleWeightColumnName, + FeatureColumnName = featureColumnName, + ExampleWeightColumnName = exampleWeightColumnName, ClustersCount = clustersCount }; return new KMeansPlusPlusTrainer(env, options); diff --git a/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs b/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs index f1db9a75db..cbb02a90fe 100644 --- a/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs +++ b/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs @@ -116,12 +116,12 @@ public sealed class Options : UnsupervisedTrainerInputBaseWithWeight /// The to use. /// The advanced options of the algorithm. internal KMeansPlusPlusTrainer(IHostEnvironment env, Options options) - : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), default, TrainerUtils.MakeR4ScalarWeightColumn(options.WeightColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), default, TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName)) { Host.CheckValue(options, nameof(options)); Host.CheckUserArg(options.ClustersCount > 0, nameof(options.ClustersCount), "Must be positive"); - _featureColumn = options.FeatureColumn; + _featureColumn = options.FeatureColumnName; _k = options.ClustersCount; @@ -250,7 +250,7 @@ internal static CommonOutputs.ClusteringOutput TrainKMeans(IHostEnvironment env, return TrainerEntryPointsUtils.Train(host, input, () => new KMeansPlusPlusTrainer(host, input), - getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } private protected override SchemaShape.Column[] GetOutputColumnsCore(SchemaShape inputSchema) diff --git a/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs b/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs index f8bdaebfb9..581bbc0b59 100644 --- a/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs +++ b/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs @@ -84,9 +84,9 @@ public static Scalar LightGbm(this RegressionCatalog.RegressionTrainers c var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new LightGbmRegressorTrainer(env, options); if (onFit != null) @@ -171,9 +171,9 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new LightGbmBinaryTrainer(env, options); @@ -257,10 +257,10 @@ public static Scalar LightGbm(this RankingCatalog.RankingTrainers c var rec = new TrainerEstimatorReconciler.Ranker( (env, labelName, featuresName, groupIdName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.GroupIdColumn = groupIdName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.RowGroupColumnName = groupIdName; + options.ExampleWeightColumnName = weightsName; var trainer = new LightGbmRankingTrainer(env, options); @@ -350,9 +350,9 @@ public static (Vector score, Key predictedLabel) var rec = new TrainerEstimatorReconciler.MulticlassClassifier( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new LightGbmMulticlassTrainer(env, options); diff --git a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs index e1600af965..5df67201f8 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs @@ -94,7 +94,7 @@ public sealed class LightGbmBinaryTrainer : LightGbmTrainerBase PredictionKind.BinaryClassification; internal LightGbmBinaryTrainer(IHostEnvironment env, Options options) - : base(env, LoadNameValue, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(env, LoadNameValue, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { } @@ -191,8 +191,8 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmBinaryTrainer(host, input), - getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs index 2ef269dfd1..67e709c5c6 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs @@ -34,7 +34,7 @@ public sealed class LightGbmMulticlassTrainer : LightGbmTrainerBase PredictionKind.MultiClassClassification; internal LightGbmMulticlassTrainer(IHostEnvironment env, Options options) - : base(env, LoadNameValue, options, TrainerUtils.MakeU4ScalarColumn(options.LabelColumn)) + : base(env, LoadNameValue, options, TrainerUtils.MakeU4ScalarColumn(options.LabelColumnName)) { _numClass = -1; } @@ -248,8 +248,8 @@ public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHost return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmMulticlassTrainer(host, input), - getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs index cea09fa3da..482a04f0d9 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs @@ -81,7 +81,7 @@ public sealed class LightGbmRankingTrainer : LightGbmTrainerBase PredictionKind.Ranking; internal LightGbmRankingTrainer(IHostEnvironment env, Options options) - : base(env, LoadNameValue, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) + : base(env, LoadNameValue, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } @@ -203,9 +203,9 @@ public static CommonOutputs.RankingOutput TrainRanking(IHostEnvironment env, Opt return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmRankingTrainer(host, input), - getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), - getGroup: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.GroupIdColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), + getGroup: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName)); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs index ae60ec6141..3729154cbd 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs @@ -107,7 +107,7 @@ internal LightGbmRegressorTrainer(IHostEnvironment env, } internal LightGbmRegressorTrainer(IHostEnvironment env, Options options) - : base(env, LoadNameValue, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) + : base(env, LoadNameValue, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } @@ -176,8 +176,8 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en return TrainerEntryPointsUtils.Train(host, input, () => new LightGbmRegressorTrainer(host, input), - getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmTrainerBase.cs b/src/Microsoft.ML.LightGBM/LightGbmTrainerBase.cs index c47698f6f7..614251c117 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmTrainerBase.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmTrainerBase.cs @@ -75,17 +75,17 @@ private protected LightGbmTrainerBase(IHostEnvironment env, LightGbmTrainerOptions.LearningRate = learningRate; LightGbmTrainerOptions.NumBoostRound = numBoostRound; - LightGbmTrainerOptions.LabelColumn = label.Name; - LightGbmTrainerOptions.FeatureColumn = featureColumn; - LightGbmTrainerOptions.WeightColumn = weightColumn; - LightGbmTrainerOptions.GroupIdColumn = groupIdColumn; + LightGbmTrainerOptions.LabelColumnName = label.Name; + LightGbmTrainerOptions.FeatureColumnName = featureColumn; + LightGbmTrainerOptions.ExampleWeightColumnName = weightColumn; + LightGbmTrainerOptions.RowGroupColumnName = groupIdColumn; InitParallelTraining(); } private protected LightGbmTrainerBase(IHostEnvironment env, string name, Options options, SchemaShape.Column label) - : base(Contracts.CheckRef(env, nameof(env)).Register(name), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), label, - TrainerUtils.MakeR4ScalarWeightColumn(options.WeightColumn), TrainerUtils.MakeU4ScalarColumn(options.GroupIdColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(name), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), label, + TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName), TrainerUtils.MakeU4ScalarColumn(options.RowGroupColumnName)) { Host.CheckValue(options, nameof(options)); diff --git a/src/Microsoft.ML.PCA/PcaTrainer.cs b/src/Microsoft.ML.PCA/PcaTrainer.cs index a511dc3c84..9c20972847 100644 --- a/src/Microsoft.ML.PCA/PcaTrainer.cs +++ b/src/Microsoft.ML.PCA/PcaTrainer.cs @@ -109,7 +109,7 @@ internal RandomizedPcaTrainer(IHostEnvironment env, } internal RandomizedPcaTrainer(IHostEnvironment env, Options options) - :this(env, options, options.FeatureColumn, options.WeightColumn) + :this(env, options, options.FeatureColumnName, options.ExampleWeightColumnName) { } @@ -361,7 +361,7 @@ internal static CommonOutputs.AnomalyDetectionOutput TrainPcaAnomaly(IHostEnviro return TrainerEntryPointsUtils.Train(host, input, () => new RandomizedPcaTrainer(host, input), - getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs index 15b0d479bd..64bbc07c8e 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FactorizationMachineTrainer.cs @@ -83,7 +83,7 @@ public sealed class Options : TrainerInputBaseWithWeight public bool Normalize = true; /// - /// Extra feature column names. The column named stores features from the first field. + /// Extra feature column names. The column named stores features from the first field. /// The i-th string in stores the name of the (i+1)-th field's feature column. /// [Argument(ArgumentType.Multiple, HelpText = "Extra columns to use for feature vectors. The i-th specified string denotes the column containing features form the (i+1)-th field." + @@ -162,18 +162,18 @@ internal FieldAwareFactorizationMachineBinaryClassificationTrainer(IHostEnvironm Initialize(env, options); var extraColumnLength = (options.ExtraFeatureColumns != null ? options.ExtraFeatureColumns.Length : 0); - // There can be multiple feature columns in FFM, jointly specified by args.FeatureColumn and args.ExtraFeatureColumns. + // There can be multiple feature columns in FFM, jointly specified by args.FeatureColumnName and args.ExtraFeatureColumns. FeatureColumns = new SchemaShape.Column[1 + extraColumnLength]; // Treat the default feature column as the 1st field. - FeatureColumns[0] = new SchemaShape.Column(options.FeatureColumn, SchemaShape.Column.VectorKind.Vector, NumberDataViewType.Single, false); + FeatureColumns[0] = new SchemaShape.Column(options.FeatureColumnName, SchemaShape.Column.VectorKind.Vector, NumberDataViewType.Single, false); // Add 2nd, 3rd, and other fields from a FFM-specific argument, args.ExtraFeatureColumns. for (int i = 0; i < extraColumnLength; i++) FeatureColumns[i + 1] = new SchemaShape.Column(options.ExtraFeatureColumns[i], SchemaShape.Column.VectorKind.Vector, NumberDataViewType.Single, false); - LabelColumn = new SchemaShape.Column(options.LabelColumn, SchemaShape.Column.VectorKind.Scalar, BooleanDataViewType.Instance, false); - WeightColumn = options.WeightColumn != null ? new SchemaShape.Column(options.WeightColumn, SchemaShape.Column.VectorKind.Scalar, NumberDataViewType.Single, false) : default; + LabelColumn = new SchemaShape.Column(options.LabelColumnName, SchemaShape.Column.VectorKind.Scalar, BooleanDataViewType.Instance, false); + WeightColumn = options.ExampleWeightColumnName != null ? new SchemaShape.Column(options.ExampleWeightColumnName, SchemaShape.Column.VectorKind.Scalar, NumberDataViewType.Single, false) : default; } /// @@ -514,7 +514,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, () => new FieldAwareFactorizationMachineBinaryClassificationTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } /// diff --git a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs index 1e05fbeb67..0dde905f31 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs @@ -162,9 +162,9 @@ internal LbfgsTrainerBase(IHostEnvironment env, bool enforceNoNegativity) : this(env, new TOptions { - FeatureColumn = featureColumn, - LabelColumn = labelColumn.Name, - WeightColumn = weightColumn, + FeatureColumnName = featureColumn, + LabelColumnName = labelColumn.Name, + ExampleWeightColumnName = weightColumn, L1Weight = l1Weight, L2Weight = l2Weight, OptTol = optimizationTolerance, @@ -179,8 +179,8 @@ internal LbfgsTrainerBase(IHostEnvironment env, TOptions options, SchemaShape.Column labelColumn, Action advancedSettings = null) - : base(Contracts.CheckRef(env, nameof(env)).Register(RegisterName), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), - labelColumn, TrainerUtils.MakeR4ScalarWeightColumn(options.WeightColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(RegisterName), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), + labelColumn, TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName)) { Host.CheckValue(options, nameof(options)); LbfgsTrainerOptions = options; @@ -188,9 +188,9 @@ internal LbfgsTrainerBase(IHostEnvironment env, // Apply the advanced args, if the user supplied any. advancedSettings?.Invoke(options); - options.FeatureColumn = FeatureColumn.Name; - options.LabelColumn = LabelColumn.Name; - options.WeightColumn = WeightColumn.Name; + options.FeatureColumnName = FeatureColumn.Name; + options.LabelColumnName = LabelColumn.Name; + options.ExampleWeightColumnName = WeightColumn.Name; Host.CheckUserArg(!LbfgsTrainerOptions.UseThreads || LbfgsTrainerOptions.NumThreads > 0 || LbfgsTrainerOptions.NumThreads == null, nameof(LbfgsTrainerOptions.NumThreads), "numThreads must be positive (or empty for default)"); Host.CheckUserArg(LbfgsTrainerOptions.L2Weight >= 0, nameof(LbfgsTrainerOptions.L2Weight), "Must be non-negative"); @@ -242,9 +242,9 @@ private static TOptions ArgsInit(string featureColumn, SchemaShape.Column labelC { var args = new TOptions { - FeatureColumn = featureColumn, - LabelColumn = labelColumn.Name, - WeightColumn = weightColumn, + FeatureColumnName = featureColumn, + LabelColumnName = labelColumn.Name, + ExampleWeightColumnName = weightColumn, L1Weight = l1Weight, L2Weight = l2Weight, OptTol = optimizationTolerance, @@ -252,7 +252,7 @@ private static TOptions ArgsInit(string featureColumn, SchemaShape.Column labelC EnforceNonNegativity = enforceNoNegativity }; - args.WeightColumn = weightColumn; + args.ExampleWeightColumnName = weightColumn; return args; } diff --git a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs index dd8cd838cb..e38f779d60 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs @@ -98,7 +98,7 @@ internal LogisticRegression(IHostEnvironment env, /// Initializes a new instance of /// internal LogisticRegression(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { _posWeight = 0; ShowTrainingStats = LbfgsTrainerOptions.ShowTrainingStats; @@ -421,8 +421,8 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro return TrainerEntryPointsUtils.Train(host, input, () => new LogisticRegression(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs index ec720980eb..4d4469c10c 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs @@ -101,7 +101,7 @@ internal MulticlassLogisticRegression(IHostEnvironment env, /// Initializes a new instance of /// internal MulticlassLogisticRegression(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeU4ScalarColumn(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeU4ScalarColumn(options.LabelColumnName)) { ShowTrainingStats = LbfgsTrainerOptions.ShowTrainingStats; } @@ -1014,8 +1014,8 @@ internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHo return TrainerEntryPointsUtils.Train(host, input, () => new MulticlassLogisticRegression(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/ModelStatistics.cs b/src/Microsoft.ML.StandardLearners/Standard/ModelStatistics.cs index 9c71cc9858..79f6a0dfa1 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/ModelStatistics.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/ModelStatistics.cs @@ -299,7 +299,7 @@ private List GetUnorderedCoefficientStatistics(LinearBina var names = default(VBuffer>); featureColumn.Annotations.GetValue(AnnotationUtils.Kinds.SlotNames, ref names); - _env.Assert(names.Length > 0, "FeatureColumn has no metadata."); + _env.Assert(names.Length > 0, "FeatureColumnName has no metadata."); ReadOnlySpan stdErrorValues = _coeffStdError.Value.GetValues(); const Double sqrt2 = 1.41421356237; // Math.Sqrt(2); diff --git a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs index dfeb11ef9f..dd4c9ee3d2 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs @@ -68,8 +68,8 @@ internal MultiClassNaiveBayesTrainer(IHostEnvironment env, /// Initializes a new instance of /// internal MultiClassNaiveBayesTrainer(IHostEnvironment env, Options options) - : base(Contracts.CheckRef(env, nameof(env)).Register(LoadName), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), - TrainerUtils.MakeU4ScalarColumn(options.LabelColumn)) + : base(Contracts.CheckRef(env, nameof(env)).Register(LoadName), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), + TrainerUtils.MakeU4ScalarColumn(options.LabelColumnName)) { Host.CheckValue(options, nameof(options)); } @@ -176,7 +176,7 @@ internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClassNaiv return TrainerEntryPointsUtils.Train(host, input, () => new MultiClassNaiveBayesTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs index e40f982bbc..f65a976227 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/AveragedPerceptron.cs @@ -109,7 +109,7 @@ public override LinearBinaryModelParameters CreatePredictor() } internal AveragedPerceptronTrainer(IHostEnvironment env, Options options) - : base(options, env, UserNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(options, env, UserNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { _args = options; LossFunction = _args.LossFunction.CreateComponent(env); @@ -137,8 +137,8 @@ internal AveragedPerceptronTrainer(IHostEnvironment env, int numIterations = Options.AveragedDefault.NumIterations) : this(env, new Options { - LabelColumn = labelColumn, - FeatureColumn = featureColumn, + LabelColumnName = labelColumn, + FeatureColumnName = featureColumn, LearningRate = learningRate, DecreaseLearningRate = decreaseLearningRate, L2RegularizerWeight = l2RegularizerWeight, @@ -215,7 +215,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro return TrainerEntryPointsUtils.Train(host, input, () => new AveragedPerceptronTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs index 6c1dc804d3..1c07b6c98e 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs @@ -241,8 +241,8 @@ internal LinearSvmTrainer(IHostEnvironment env, int numIterations = Options.OnlineDefault.NumIterations) : this(env, new Options { - LabelColumn = labelColumn, - FeatureColumn = featureColumn, + LabelColumnName = labelColumn, + FeatureColumnName = featureColumn, WeightColumn = weightColumn, NumberOfIterations = numIterations, }) @@ -250,7 +250,7 @@ internal LinearSvmTrainer(IHostEnvironment env, } internal LinearSvmTrainer(IHostEnvironment env, Options options) - : base(options, env, UserNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(options, env, UserNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { Contracts.CheckUserArg(options.Lambda > 0, nameof(options.Lambda), UserErrorPositive); Contracts.CheckUserArg(options.BatchSize > 0, nameof(options.BatchSize), UserErrorPositive); @@ -288,7 +288,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainLinearSvm(IHostEnv return TrainerEntryPointsUtils.Train(host, input, () => new LinearSvmTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs index 0cf306e8bc..b83c1b24d4 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs @@ -111,8 +111,8 @@ internal OnlineGradientDescentTrainer(IHostEnvironment env, DecreaseLearningRate = decreaseLearningRate, L2RegularizerWeight = l2RegularizerWeight, NumberOfIterations = numIterations, - LabelColumn = labelColumn, - FeatureColumn = featureColumn, + LabelColumnName = labelColumn, + FeatureColumnName = featureColumn, LossFunction = new TrivialFactory(lossFunction ?? new SquaredLoss()) }) { @@ -131,7 +131,7 @@ public TrivialFactory(IRegressionLoss loss) } internal OnlineGradientDescentTrainer(IHostEnvironment env, Options options) - : base(options, env, UserNameValue, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) + : base(options, env, UserNameValue, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { LossFunction = options.LossFunction.CreateComponent(env); } @@ -169,7 +169,7 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment return TrainerEntryPointsUtils.Train(host, input, () => new OnlineGradientDescentTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } private protected override RegressionPredictionTransformer MakeTransformer(LinearRegressionModelParameters model, DataViewSchema trainSchema) diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs index a1bdc2fe0a..0fc38d696e 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/OnlineLinear.cs @@ -252,7 +252,7 @@ public virtual float Margin(in VBuffer feat) private protected virtual bool NeedCalibration => false; private protected OnlineLinearTrainer(OnlineLinearOptions options, IHostEnvironment env, string name, SchemaShape.Column label) - : base(Contracts.CheckRef(env, nameof(env)).Register(name), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), label, TrainerUtils.MakeR4ScalarWeightColumn(options.InitialWeights)) + : base(Contracts.CheckRef(env, nameof(env)).Register(name), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), label, TrainerUtils.MakeR4ScalarWeightColumn(options.InitialWeights)) { Contracts.CheckValue(options, nameof(options)); Contracts.CheckUserArg(options.NumberOfIterations > 0, nameof(options.NumberOfIterations), UserErrorPositive); diff --git a/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs index 42f51d62a1..165f662cc9 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs @@ -70,7 +70,7 @@ internal PoissonRegression(IHostEnvironment env, /// Initializes a new instance of /// internal PoissonRegression(IHostEnvironment env, Options options) - : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } @@ -184,8 +184,8 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment return TrainerEntryPointsUtils.Train(host, input, () => new PoissonRegression(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs b/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs index 2814bf6420..9c1c628101 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs @@ -250,8 +250,8 @@ private static TOptions ArgsInit(string featureColumnName, SchemaShape.Column la { var args = new TOptions(); - args.FeatureColumn = featureColumnName; - args.LabelColumn = labelColumn.Name; + args.FeatureColumnName = featureColumnName; + args.LabelColumnName = labelColumn.Name; return args; } @@ -264,7 +264,7 @@ internal SdcaTrainerBase(IHostEnvironment env, string featureColumnName, SchemaS internal SdcaTrainerBase(IHostEnvironment env, TOptions options, SchemaShape.Column label, SchemaShape.Column weight = default, float? l2Const = null, float? l1Threshold = null, int? maxIterations = null) - : base(Contracts.CheckRef(env, nameof(env)).Register(RegisterName), TrainerUtils.MakeR4VecFeature(options.FeatureColumn), label, weight) + : base(Contracts.CheckRef(env, nameof(env)).Register(RegisterName), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), label, weight) { SdcaTrainerOptions = options; SdcaTrainerOptions.L2Const = l2Const ?? options.L2Const; @@ -1463,7 +1463,7 @@ private protected SdcaBinaryTrainerBase(IHostEnvironment env, } private protected SdcaBinaryTrainerBase(IHostEnvironment env, BinaryOptionsBase options, ISupportSdcaClassificationLoss loss = null, bool doCalibration = false) - : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn)) + : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { _loss = loss ?? new LogLossFactory().CreateComponent(env); Loss = _loss; @@ -1866,9 +1866,9 @@ internal SgdBinaryTrainerBase(IHostEnvironment env, _options.InitLearningRate = initLearningRate; _options.L2Weight = l2Weight; - _options.FeatureColumn = featureColumn; - _options.LabelColumn = labelColumn; - _options.WeightColumn = weightColumn; + _options.FeatureColumnName = featureColumn; + _options.LabelColumnName = labelColumn; + _options.ExampleWeightColumnName = weightColumn; Loss = loss ?? new LogLoss(); Info = new TrainerInfo(calibration: false, supportIncrementalTrain: true); } @@ -1881,7 +1881,7 @@ internal SgdBinaryTrainerBase(IHostEnvironment env, /// Loss function would be minimized. /// Set to true if a calibration step should be happen after training. Use false otherwise. internal SgdBinaryTrainerBase(IHostEnvironment env, OptionsBase options, IClassificationLoss loss = null, bool doCalibration = false) - : base(env, options.FeatureColumn, TrainerUtils.MakeBoolScalarLabel(options.LabelColumn), options.WeightColumn) + : base(env, options.FeatureColumnName, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName), options.ExampleWeightColumnName) { options.Check(env); Loss = loss; @@ -2310,8 +2310,8 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro return TrainerEntryPointsUtils.Train(host, input, () => new LegacySgdBinaryTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.WeightColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } } @@ -2334,7 +2334,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro return TrainerEntryPointsUtils.Train(host, input, () => new LegacySdcaBinaryTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn), + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), calibrator: input.Calibrator, maxCalibrationExamples: input.MaxCalibrationExamples); } } diff --git a/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs b/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs index 76b99736b6..561d8a97f1 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/SdcaMultiClass.cs @@ -84,7 +84,7 @@ internal SdcaMultiClassTrainer(IHostEnvironment env, Options options, } internal SdcaMultiClassTrainer(IHostEnvironment env, Options options) - : this(env, options, options.FeatureColumn, options.LabelColumn) + : this(env, options, options.FeatureColumnName, options.LabelColumnName) { } @@ -455,7 +455,7 @@ public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHost return TrainerEntryPointsUtils.Train(host, input, () => new SdcaMultiClassTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } } } \ No newline at end of file diff --git a/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs index 8bd3f49679..3cb1a42dae 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/SdcaRegression.cs @@ -87,7 +87,7 @@ internal SdcaRegressionTrainer(IHostEnvironment env, Options options, string fea } internal SdcaRegressionTrainer(IHostEnvironment env, Options options) - : this(env, options, options.FeatureColumn, options.LabelColumn) + : this(env, options, options.FeatureColumnName, options.LabelColumnName) { } @@ -178,7 +178,7 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en return TrainerEntryPointsUtils.Train(host, input, () => new SdcaRegressionTrainer(host, input), - () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumn)); + () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } } } \ No newline at end of file diff --git a/src/Microsoft.ML.StaticPipe/KMeansStatic.cs b/src/Microsoft.ML.StaticPipe/KMeansStatic.cs index 0b46f49385..50921467b6 100644 --- a/src/Microsoft.ML.StaticPipe/KMeansStatic.cs +++ b/src/Microsoft.ML.StaticPipe/KMeansStatic.cs @@ -40,9 +40,9 @@ public static (Vector score, Key predictedLabel) KMeans(this Cluste { var options = new KMeansPlusPlusTrainer.Options { - FeatureColumn = featuresName, + FeatureColumnName = featuresName, ClustersCount = clustersCount, - WeightColumn = weightsName + ExampleWeightColumnName = weightsName }; var trainer = new KMeansPlusPlusTrainer(env, options); @@ -80,8 +80,8 @@ public static (Vector score, Key predictedLabel) KMeans(this Cluste var rec = new TrainerEstimatorReconciler.Clustering( (env, featuresName, weightsName) => { - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new KMeansPlusPlusTrainer(env, options); diff --git a/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs b/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs index 1c5eec3191..bc7066fbad 100644 --- a/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs +++ b/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs @@ -90,9 +90,9 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new LogisticRegression(env, options); @@ -186,9 +186,9 @@ public static Scalar PoissonRegression(this RegressionCatalog.RegressionT var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new PoissonRegression(env, options); @@ -283,9 +283,9 @@ public static (Vector score, Key predictedLabel) var rec = new TrainerEstimatorReconciler.MulticlassClassifier( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new MulticlassLogisticRegression(env, options); diff --git a/src/Microsoft.ML.StaticPipe/OnlineLearnerStatic.cs b/src/Microsoft.ML.StaticPipe/OnlineLearnerStatic.cs index 02e961f914..18f32cb119 100644 --- a/src/Microsoft.ML.StaticPipe/OnlineLearnerStatic.cs +++ b/src/Microsoft.ML.StaticPipe/OnlineLearnerStatic.cs @@ -117,8 +117,8 @@ public static (Scalar score, Scalar predictedLabel) AveragedPercept var rec = new TrainerEstimatorReconciler.BinaryClassifierNoCalibration( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; var trainer = new AveragedPerceptronTrainer(env, options); @@ -221,8 +221,8 @@ public static Scalar OnlineGradientDescent(this RegressionCatalog.Regress var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; var trainer = new OnlineGradientDescentTrainer(env, options); diff --git a/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs b/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs index 2261c24e63..20b244a3a9 100644 --- a/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs +++ b/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs @@ -99,8 +99,8 @@ public static Scalar Sdca(this RegressionCatalog.RegressionTrainers catal var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; var trainer = new SdcaRegressionTrainer(env, options); if (onFit != null) @@ -203,8 +203,8 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; var trainer = new SdcaBinaryTrainer(env, options); if (onFit != null) @@ -310,8 +310,8 @@ public static (Scalar score, Scalar predictedLabel) SdcaNonCalibrat var rec = new TrainerEstimatorReconciler.BinaryClassifierNoCalibration( (env, labelName, featuresName, weightsName) => { - options.FeatureColumn = featuresName; - options.LabelColumn = labelName; + options.FeatureColumnName = featuresName; + options.LabelColumnName = labelName; var trainer = new SdcaNonCalibratedBinaryTrainer(env, options); if (onFit != null) @@ -407,8 +407,8 @@ public static (Vector score, Key predictedLabel) Sdca( var rec = new TrainerEstimatorReconciler.MulticlassClassifier( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; var trainer = new SdcaMultiClassTrainer(env, options); if (onFit != null) diff --git a/src/Microsoft.ML.StaticPipe/SgdStatic.cs b/src/Microsoft.ML.StaticPipe/SgdStatic.cs index d71d55db9d..dad7e9b57f 100644 --- a/src/Microsoft.ML.StaticPipe/SgdStatic.cs +++ b/src/Microsoft.ML.StaticPipe/SgdStatic.cs @@ -78,9 +78,9 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - options.FeatureColumn = featuresName; - options.LabelColumn = labelName; - options.WeightColumn = weightsName; + options.FeatureColumnName = featuresName; + options.LabelColumnName = labelName; + options.ExampleWeightColumnName = weightsName; var trainer = new SgdBinaryTrainer(env, options); @@ -161,9 +161,9 @@ public static (Scalar score, Scalar predictedLabel) StochasticGradi var rec = new TrainerEstimatorReconciler.BinaryClassifierNoCalibration( (env, labelName, featuresName, weightsName) => { - options.FeatureColumn = featuresName; - options.LabelColumn = labelName; - options.WeightColumn = weightsName; + options.FeatureColumnName = featuresName; + options.LabelColumnName = labelName; + options.ExampleWeightColumnName = weightsName; var trainer = new SgdNonCalibratedBinaryTrainer(env, options); diff --git a/src/Microsoft.ML.StaticPipe/TreeTrainersStatic.cs b/src/Microsoft.ML.StaticPipe/TreeTrainersStatic.cs index f6c6132d80..49e12c4098 100644 --- a/src/Microsoft.ML.StaticPipe/TreeTrainersStatic.cs +++ b/src/Microsoft.ML.StaticPipe/TreeTrainersStatic.cs @@ -92,9 +92,9 @@ public static Scalar FastTree(this RegressionCatalog.RegressionTrainers c var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new FastTreeRegressionTrainer(env, options); if (onFit != null) @@ -188,9 +188,9 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.ExampleWeightColumnName = weightsName; var trainer = new FastTreeBinaryClassificationTrainer(env, options); @@ -272,10 +272,10 @@ public static Scalar FastTree(this RankingCatalog.RankingTrainers c var rec = new TrainerEstimatorReconciler.Ranker( (env, labelName, featuresName, groupIdName, weightsName) => { - options.LabelColumn = labelName; - options.FeatureColumn = featuresName; - options.GroupIdColumn = groupIdName; - options.WeightColumn = weightsName; + options.LabelColumnName = labelName; + options.FeatureColumnName = featuresName; + options.RowGroupColumnName = groupIdName; + options.ExampleWeightColumnName = weightsName; var trainer = new FastTreeRankingTrainer(env, options); if (onFit != null) diff --git a/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs b/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs index 6053bdc4bd..ae03f1ea98 100644 --- a/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs +++ b/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs @@ -140,8 +140,8 @@ private FastForestRegressionModelParameters FitModel(IEnumerable pre FeatureFraction = _args.SplitRatio, NumTrees = _args.NumOfTrees, MinDocumentsInLeafs = _args.NMinForSplit, - LabelColumn = DefaultColumnNames.Label, - FeatureColumn = DefaultColumnNames.Features, + LabelColumnName = DefaultColumnNames.Label, + FeatureColumnName = DefaultColumnNames.Features, }); var predictor = trainer.Fit(view); diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs index 2bccf68ed2..6efa1eb22a 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs @@ -387,18 +387,18 @@ public void EntryPointInputBuilderOptionals() InputBuilder ib1 = new InputBuilder(Env, typeof(LogisticRegression.Options), catalog); // Ensure that InputBuilder unwraps the Optional correctly. - var weightType = ib1.GetFieldTypeOrNull("WeightColumn"); + var weightType = ib1.GetFieldTypeOrNull("ExampleWeightColumnName"); Assert.True(weightType.Equals(typeof(string))); var instance = ib1.GetInstance() as LogisticRegression.Options; - Assert.True(instance.WeightColumn == null); + Assert.True(instance.ExampleWeightColumnName == null); - ib1.TrySetValue("WeightColumn", "OtherWeight"); - Assert.Equal("OtherWeight", instance.WeightColumn); + ib1.TrySetValue("ExampleWeightColumnName", "OtherWeight"); + Assert.Equal("OtherWeight", instance.ExampleWeightColumnName); var tok = (JToken)JValue.CreateString("AnotherWeight"); - ib1.TrySetValueJson("WeightColumn", tok); - Assert.Equal("AnotherWeight", instance.WeightColumn); + ib1.TrySetValueJson("ExampleWeightColumnName", tok); + Assert.Equal("AnotherWeight", instance.ExampleWeightColumnName); } [Fact] @@ -1869,7 +1869,7 @@ public void EntryPointEvaluateRanking() 'Name': 'Transforms.LabelColumnKeyBooleanConverter', 'Inputs': { 'Data': '$output_data1', - 'LabelColumn': 'Label', + 'LabelColumnName': 'Label', 'TextKeyValues': false }, 'Outputs': { @@ -3456,7 +3456,7 @@ public void EntryPointPrepareLabelConvertPredictedLabel() 'Name': 'Transforms.LabelColumnKeyBooleanConverter', 'Inputs': {{ 'Data': '$data1', - 'LabelColumn': 'Label' + 'LabelColumnName': 'Label' }}, 'Outputs': {{ 'OutputData': '$data2' @@ -3549,10 +3549,10 @@ public void EntryPointTreeLeafFeaturizer() var fastTree = Trainers.FastTree.FastTree.TrainBinary(Env, new FastTreeBinaryClassificationTrainer.Options { - FeatureColumn = "Features", + FeatureColumnName = "Features", NumTrees = 5, NumLeaves = 4, - LabelColumn = DefaultColumnNames.Label, + LabelColumnName = DefaultColumnNames.Label, TrainingData = concat.OutputData }); @@ -3997,9 +3997,9 @@ public void TestSimpleTrainExperiment() 'Shuffle': false, 'CheckFrequency': null, 'BiasLearningRate': 0.0, - 'LabelColumn': 'Label', + 'LabelColumnName': 'Label', 'TrainingData': '$Var_51d3ddc9792d4c6eb975e600e87b8cbc', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -4026,8 +4026,8 @@ public void TestSimpleTrainExperiment() 'NumRocExamples': 100000, 'MaxAucExamples': -1, 'NumAuPrcExamples': 100000, - 'LabelColumn': null, - 'WeightColumn': null, + 'LabelColumnName': null, + 'ExampleWeightColumnName': null, 'ScoreColumn': null, 'StratColumn': null, 'Data': '$Var_be77f9c4e45c43b7a67984304c291bf5', @@ -4168,10 +4168,10 @@ public void TestCrossValidationMacro() 'NumThreads': 1, 'DenseOptimizer': false, 'EnforceNonNegativity': false, - 'WeightColumn': 'Weight1', - 'LabelColumn': 'Label', + 'ExampleWeightColumnName': 'Weight1', + 'LabelColumnName': 'Label', 'TrainingData': '$Var_8b36a1e70c9f4504973140ad15eac72f', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -4201,8 +4201,8 @@ public void TestCrossValidationMacro() 'StratificationColumn': null, 'NumFolds': 2, 'Kind': 'SignatureRegressorTrainer', - 'LabelColumn': 'Label', - 'WeightColumn': 'Weight1', + 'LabelColumnName': 'Label', + 'ExampleWeightColumnName': 'Weight1', 'GroupColumn': null, 'NameColumn': null }, @@ -4354,9 +4354,9 @@ public void TestCrossValidationMacroWithMultiClass() 'Shuffle': true, 'CheckFrequency': null, 'BiasLearningRate': 0.0, - 'LabelColumn': 'Label', + 'LabelColumnName': 'Label', 'TrainingData': '$Var_a060169d8a924964b71447904c0d2ee9', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -4385,8 +4385,8 @@ public void TestCrossValidationMacroWithMultiClass() 'StratificationColumn': null, 'NumFolds': 2, 'Kind': 'SignatureMultiClassClassifierTrainer', - 'LabelColumn': 'Label', - 'WeightColumn': null, + 'LabelColumnName': 'Label', + 'ExampleWeightColumnName': null, 'GroupColumn': null, 'NameColumn': null }, @@ -4591,10 +4591,10 @@ public void TestCrossValidationMacroMultiClassWithWarnings() 'NumThreads': 1, 'DenseOptimizer': false, 'EnforceNonNegativity': false, - 'WeightColumn': null, - 'LabelColumn': 'Label', + 'ExampleWeightColumnName': null, + 'LabelColumnName': 'Label', 'TrainingData': '$Var_fb8137cb48ac49a7b1b56aa3ed5e0b23', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -4612,8 +4612,8 @@ public void TestCrossValidationMacroMultiClassWithWarnings() 'StratificationColumn': 'Strat', 'NumFolds': 2, 'Kind': 'SignatureMultiClassClassifierTrainer', - 'LabelColumn': 'Label', - 'WeightColumn': null, + 'LabelColumnName': 'Label', + 'ExampleWeightColumnName': null, 'GroupColumn': null, 'NameColumn': null }, @@ -4761,9 +4761,9 @@ public void TestCrossValidationMacroWithStratification() 'Shuffle': true, 'CheckFrequency': null, 'BiasLearningRate': 0.0, - 'LabelColumn': 'Label', + 'LabelColumnName': 'Label', 'TrainingData': '$Var_44f5c60e439b49fe9e5bf372be4613ee', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -4792,8 +4792,8 @@ public void TestCrossValidationMacroWithStratification() 'StratificationColumn': 'Strat', 'NumFolds': 2, 'Kind': 'SignatureBinaryClassifierTrainer', - 'LabelColumn': 'Label', - 'WeightColumn': null, + 'LabelColumnName': 'Label', + 'ExampleWeightColumnName': null, 'GroupColumn': null, 'NameColumn': null }, @@ -5053,11 +5053,11 @@ public void TestCrossValidationMacroWithNonDefaultNames() 'PrintTestGraph': false, 'PrintTrainValidGraph': false, 'TestFrequency': 2147483647, - 'GroupIdColumn': 'GroupId1', - 'WeightColumn': null, - 'LabelColumn': 'Label1', + 'RowGroupColumnName': 'GroupId1', + 'ExampleWeightColumnName': null, + 'LabelColumnName': 'Label1', 'TrainingData': '$Var_8f51ed90f5b642b2a80eeb628d67a5b3', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -5087,8 +5087,8 @@ public void TestCrossValidationMacroWithNonDefaultNames() 'StratificationColumn': null, 'NumFolds': 2, 'Kind': 'SignatureRankerTrainer', - 'LabelColumn': 'Label1', - 'WeightColumn': null, + 'LabelColumnName': 'Label1', + 'ExampleWeightColumnName': null, 'GroupColumn': { 'Value': 'GroupId1', 'IsExplicit': true @@ -5269,9 +5269,9 @@ public void TestOvaMacro() 'Shuffle': true, 'CheckFrequency': null, 'BiasLearningRate': 0.0, - 'LabelColumn': 'Label', + 'LabelColumnName': 'Label', 'TrainingData': '$Var_9aa1732198964d7f979a0bbec5db66c2', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -5284,10 +5284,10 @@ public void TestOvaMacro() 'Model': '$Var_a229f40df6494a93a794ffd5480d5549' }, 'UseProbabilities': true, - 'WeightColumn': null, - 'LabelColumn': 'Label', + 'ExampleWeightColumnName': null, + 'LabelColumnName': 'Label', 'TrainingData': '$Var_672f860e44304ba8bd1c1a6e4b5ba9c5', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -5312,8 +5312,8 @@ public void TestOvaMacro() 'NumTopClassesToOutput': 3, 'NumClassesConfusionMatrix': 10, 'OutputPerClassStatistics': false, - 'LabelColumn': null, - 'WeightColumn': null, + 'LabelColumnName': null, + 'ExampleWeightColumnName': null, 'ScoreColumn': null, 'StratColumn': null, 'Data': '$Var_5454fd8c353c40288dd8c2d104be788f', @@ -5439,9 +5439,9 @@ public void TestOvaMacroWithUncalibratedLearner() 'InitialWeights': null, 'InitialWeightsDiameter': 0.0, 'Shuffle': false, - 'LabelColumn': 'Label', + 'LabelColumnName': 'Label', 'TrainingData': '$Var_9ccc8bce4f6540eb8a244ab40585602a', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -5454,10 +5454,10 @@ public void TestOvaMacroWithUncalibratedLearner() 'Model': '$Var_b47f7facc1c540e39d8b82ab64df6592' }, 'UseProbabilities': true, - 'WeightColumn': null, - 'LabelColumn': 'Label', + 'ExampleWeightColumnName': null, + 'LabelColumnName': 'Label', 'TrainingData': '$Var_f38b99289df746319edd57a3ccfb85a2', - 'FeatureColumn': 'Features', + 'FeatureColumnName': 'Features', 'NormalizeFeatures': 'Auto', 'Caching': 'Auto' }, @@ -5482,8 +5482,8 @@ public void TestOvaMacroWithUncalibratedLearner() 'NumTopClassesToOutput': 3, 'NumClassesConfusionMatrix': 10, 'OutputPerClassStatistics': false, - 'LabelColumn': null, - 'WeightColumn': null, + 'LabelColumnName': null, + 'ExampleWeightColumnName': null, 'ScoreColumn': null, 'StratColumn': null, 'Data': '$Var_a20e37dc58d84bf5a1cb13ed13eae5ba', @@ -5591,7 +5591,7 @@ public void TestTensorFlowEntryPoint() 'OutputColumns': [ 'Softmax' ], - 'LabelColumn': null, + 'LabelColumnName': null, 'TensorFlowLabel': null, 'OptimizationOperation': null, 'LossOperation': null, diff --git a/test/Microsoft.ML.Functional.Tests/Prediction.cs b/test/Microsoft.ML.Functional.Tests/Prediction.cs index 41740157ea..42197db54c 100644 --- a/test/Microsoft.ML.Functional.Tests/Prediction.cs +++ b/test/Microsoft.ML.Functional.Tests/Prediction.cs @@ -43,7 +43,7 @@ public void ReconfigurablePrediction() // Todo #2465: Allow the setting of threshold and thresholdColumn for scoring. // This is no longer possible in the API - //var newModel = new BinaryPredictionTransformer>(ml, model.Model, trainData.Schema, model.FeatureColumn, threshold: 0.01f, thresholdColumn: DefaultColumnNames.Probability); + //var newModel = new BinaryPredictionTransformer>(ml, model.Model, trainData.Schema, model.FeatureColumnName, threshold: 0.01f, thresholdColumn: DefaultColumnNames.Probability); //var newScoredTest = newModel.Transform(pipeline.Transform(testData)); //var newMetrics = mlContext.BinaryClassification.Evaluate(scoredTest); // And the Threshold and ThresholdColumn properties are not settable. diff --git a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs index 1493327d20..721a678f21 100644 --- a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs +++ b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs @@ -612,10 +612,10 @@ public void TestTreeEnsembleCombiner() { fastTrees[i] = FastTree.TrainBinary(ML, new FastTreeBinaryClassificationTrainer.Options { - FeatureColumn = "Features", + FeatureColumnName = "Features", NumTrees = 5, NumLeaves = 4, - LabelColumn = DefaultColumnNames.Label, + LabelColumnName = DefaultColumnNames.Label, TrainingData = dataView }).PredictorModel; } @@ -634,11 +634,11 @@ public void TestTreeEnsembleCombinerWithCategoricalSplits() { fastTrees[i] = FastTree.TrainBinary(ML, new FastTreeBinaryClassificationTrainer.Options { - FeatureColumn = "Features", + FeatureColumnName = "Features", NumTrees = 5, NumLeaves = 4, CategoricalSplit = true, - LabelColumn = DefaultColumnNames.Label, + LabelColumnName = DefaultColumnNames.Label, TrainingData = cat }).PredictorModel; } @@ -734,32 +734,32 @@ public void TestEnsembleCombiner() { FastTree.TrainBinary(ML, new FastTreeBinaryClassificationTrainer.Options { - FeatureColumn = "Features", + FeatureColumnName = "Features", NumTrees = 5, NumLeaves = 4, - LabelColumn = DefaultColumnNames.Label, + LabelColumnName = DefaultColumnNames.Label, TrainingData = dataView }).PredictorModel, AveragedPerceptronTrainer.TrainBinary(ML, new AveragedPerceptronTrainer.Options() { - FeatureColumn = "Features", - LabelColumn = DefaultColumnNames.Label, + FeatureColumnName = "Features", + LabelColumnName = DefaultColumnNames.Label, NumberOfIterations = 2, TrainingData = dataView, NormalizeFeatures = NormalizeOption.No }).PredictorModel, LogisticRegression.TrainBinary(ML, new LogisticRegression.Options() { - FeatureColumn = "Features", - LabelColumn = DefaultColumnNames.Label, + FeatureColumnName = "Features", + LabelColumnName = DefaultColumnNames.Label, OptTol = 10e-4F, TrainingData = dataView, NormalizeFeatures = NormalizeOption.No }).PredictorModel, LogisticRegression.TrainBinary(ML, new LogisticRegression.Options() { - FeatureColumn = "Features", - LabelColumn = DefaultColumnNames.Label, + FeatureColumnName = "Features", + LabelColumnName = DefaultColumnNames.Label, OptTol = 10e-3F, TrainingData = dataView, NormalizeFeatures = NormalizeOption.No @@ -779,24 +779,24 @@ public void TestMultiClassEnsembleCombiner() { LightGbm.TrainMultiClass(Env, new Options { - FeatureColumn = "Features", + FeatureColumnName = "Features", NumBoostRound = 5, NumLeaves = 4, - LabelColumn = DefaultColumnNames.Label, + LabelColumnName = DefaultColumnNames.Label, TrainingData = dataView }).PredictorModel, LogisticRegression.TrainMultiClass(Env, new MulticlassLogisticRegression.Options() { - FeatureColumn = "Features", - LabelColumn = DefaultColumnNames.Label, + FeatureColumnName = "Features", + LabelColumnName = DefaultColumnNames.Label, OptTol = 10e-4F, TrainingData = dataView, NormalizeFeatures = NormalizeOption.No }).PredictorModel, LogisticRegression.TrainMultiClass(Env, new MulticlassLogisticRegression.Options() { - FeatureColumn = "Features", - LabelColumn = DefaultColumnNames.Label, + FeatureColumnName = "Features", + LabelColumnName = DefaultColumnNames.Label, OptTol = 10e-3F, TrainingData = dataView, NormalizeFeatures = NormalizeOption.No diff --git a/test/Microsoft.ML.Tests/OnnxConversionTest.cs b/test/Microsoft.ML.Tests/OnnxConversionTest.cs index 308aafeda1..e573c3df22 100644 --- a/test/Microsoft.ML.Tests/OnnxConversionTest.cs +++ b/test/Microsoft.ML.Tests/OnnxConversionTest.cs @@ -135,7 +135,7 @@ public void KmeansOnnxConversionTest() var pipeline = mlContext.Transforms.Normalize("Features"). Append(mlContext.Clustering.Trainers.KMeans(new Trainers.KMeans.KMeansPlusPlusTrainer.Options { - FeatureColumn = DefaultColumnNames.Features, + FeatureColumnName = DefaultColumnNames.Features, MaxIterations = 1, ClustersCount = 4, NumThreads = 1, diff --git a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs index eb89c35dd8..151abf5229 100644 --- a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs +++ b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs @@ -683,8 +683,8 @@ private void ExecuteTFTransformMNISTConvTrainingTest(bool shuffle, int? shuffleS .AppendCacheCheckpoint(mlContext) .Append(mlContext.MulticlassClassification.Trainers.LightGbm(new LightGBM.Options() { - LabelColumn = "Label", - FeatureColumn = "Features", + LabelColumnName = "Label", + FeatureColumnName = "Features", Seed = 1, NThread = 1, NumBoostRound = 1 diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs b/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs index 6e53eab6ad..74cd7ef605 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs @@ -22,7 +22,7 @@ public void FfmBinaryClassificationWithAdvancedArguments() var ffmArgs = new FieldAwareFactorizationMachineBinaryClassificationTrainer.Options(); // Customized the field names. - ffmArgs.FeatureColumn = nameof(DatasetUtils.FfmExample.Field0); // First field. + ffmArgs.FeatureColumnName = nameof(DatasetUtils.FfmExample.Field0); // First field. ffmArgs.ExtraFeatureColumns = new[]{ nameof(DatasetUtils.FfmExample.Field1), nameof(DatasetUtils.FfmExample.Field2) }; var pipeline = mlContext.BinaryClassification.Trainers.FieldAwareFactorizationMachine(ffmArgs); @@ -45,7 +45,7 @@ public void FieldAwareFactorizationMachine_Estimator() .Read(GetDataPath(TestDatasets.breastCancer.trainFilename)); var ffmArgs = new FieldAwareFactorizationMachineBinaryClassificationTrainer.Options { - FeatureColumn = "Feature1", // Features from the 1st field. + FeatureColumnName = "Feature1", // Features from the 1st field. ExtraFeatureColumns = new[] { "Feature2", "Feature3", "Feature4" }, // 2nd field's feature column, 3rd field's feature column, 4th field's feature column. Shuffle = false, NumberOfIterations = 3, diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs index 506da31ccf..68c887ba3f 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs @@ -86,8 +86,8 @@ public void MetacomponentsFeaturesRenamed() var sdcaTrainer = ML.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( new SdcaNonCalibratedBinaryTrainer.Options { - LabelColumn = "Label", - FeatureColumn = "Vars", + LabelColumnName = "Label", + FeatureColumnName = "Vars", MaxIterations = 100, Shuffle = true, NumThreads = 1, }); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs index 430dbc7dbd..e4e98b4260 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs @@ -74,8 +74,8 @@ public void KMeansEstimator() // Pipeline. var pipeline = new KMeansPlusPlusTrainer(Env, new KMeansPlusPlusTrainer.Options { - FeatureColumn = featureColumn, - WeightColumn = weights, + FeatureColumnName = featureColumn, + ExampleWeightColumnName = weights, InitAlgorithm = KMeansPlusPlusTrainer.InitAlgorithm.KMeansParallel, }); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs index 32c59258dd..0e7d46b984 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs @@ -114,9 +114,9 @@ public void FastTreeRankerEstimator() var trainer = ML.Ranking.Trainers.FastTree( new FastTreeRankingTrainer.Options { - FeatureColumn = "NumericFeatures", + FeatureColumnName = "NumericFeatures", NumTrees = 10, - GroupIdColumn = "Group" + RowGroupColumnName = "Group" }); var pipeWithTrainer = pipe.Append(trainer); @@ -135,7 +135,7 @@ public void LightGBMRankerEstimator() { var (pipe, dataView) = GetRankingPipeline(); - var trainer = ML.Ranking.Trainers.LightGbm(new Options() { LabelColumn = "Label0", FeatureColumn = "NumericFeatures", GroupIdColumn = "Group", LearningRate = 0.4 }); + var trainer = ML.Ranking.Trainers.LightGbm(new Options() { LabelColumnName = "Label0", FeatureColumnName = "NumericFeatures", RowGroupColumnName = "Group", LearningRate = 0.4 }); var pipeWithTrainer = pipe.Append(trainer); TestEstimatorCore(pipeWithTrainer, dataView); From c5f4204f1d8dd8c06b4cd714f606dac9c61f07f1 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Wed, 27 Feb 2019 11:40:13 -0800 Subject: [PATCH 09/11] fix tests --- .../Common/EntryPoints/core_manifest.json | 224 +++++++++--------- 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/test/BaselineOutput/Common/EntryPoints/core_manifest.json b/test/BaselineOutput/Common/EntryPoints/core_manifest.json index 984e570840..d3e0180dbd 100644 --- a/test/BaselineOutput/Common/EntryPoints/core_manifest.json +++ b/test/BaselineOutput/Common/EntryPoints/core_manifest.json @@ -2097,7 +2097,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -2118,7 +2118,7 @@ "Default": true }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -2130,7 +2130,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -2336,7 +2336,7 @@ "Default": true }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -2348,7 +2348,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -2360,7 +2360,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -4166,7 +4166,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -4178,7 +4178,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -4524,7 +4524,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -4548,7 +4548,7 @@ "Default": null }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -4725,7 +4725,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -4749,7 +4749,7 @@ "Default": null }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -4926,7 +4926,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -4950,7 +4950,7 @@ "Default": null }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -5144,7 +5144,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -5176,7 +5176,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -5188,7 +5188,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -5200,7 +5200,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -5794,7 +5794,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -5826,7 +5826,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -5838,7 +5838,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -5850,7 +5850,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -6418,7 +6418,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -6450,7 +6450,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -6480,7 +6480,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -6492,7 +6492,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -7329,7 +7329,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -7361,7 +7361,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -7391,7 +7391,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -7403,7 +7403,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -8321,7 +8321,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -8353,7 +8353,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -8383,7 +8383,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -8395,7 +8395,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -9220,7 +9220,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -9252,7 +9252,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -9282,7 +9282,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -9294,7 +9294,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -10125,7 +10125,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -10154,7 +10154,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -10184,7 +10184,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -10376,7 +10376,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -10408,7 +10408,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -10438,7 +10438,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -10676,7 +10676,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -10708,7 +10708,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -10738,7 +10738,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -10956,7 +10956,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -10968,7 +10968,7 @@ "Default": "Features" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -11221,7 +11221,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -11247,7 +11247,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -11259,7 +11259,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -11271,7 +11271,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -11724,7 +11724,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -11750,7 +11750,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -11762,7 +11762,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -11774,7 +11774,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -12227,7 +12227,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -12253,7 +12253,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -12265,7 +12265,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -12277,7 +12277,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -12730,7 +12730,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -12756,7 +12756,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -12768,7 +12768,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -12780,7 +12780,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -13152,7 +13152,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -13164,7 +13164,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -13420,7 +13420,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -13432,7 +13432,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -13444,7 +13444,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -13731,7 +13731,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -13743,7 +13743,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -13755,7 +13755,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -14042,7 +14042,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -14054,7 +14054,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -14139,7 +14139,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -14151,7 +14151,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -14452,7 +14452,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -14464,7 +14464,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -14476,7 +14476,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -14594,7 +14594,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -14606,7 +14606,7 @@ "Default": "Features" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -14760,7 +14760,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -14772,7 +14772,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -14784,7 +14784,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -15106,7 +15106,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -15118,7 +15118,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -15410,7 +15410,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -15422,7 +15422,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -15679,7 +15679,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -15691,7 +15691,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -15901,7 +15901,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -15913,7 +15913,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -15925,7 +15925,7 @@ "Default": "Label" }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -16185,7 +16185,7 @@ "IsNullable": false }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -16197,7 +16197,7 @@ "Default": "Features" }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -25116,7 +25116,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -25148,7 +25148,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -25178,7 +25178,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -25190,7 +25190,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -26009,7 +26009,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -26041,7 +26041,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -26071,7 +26071,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -26083,7 +26083,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -26983,7 +26983,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -27015,7 +27015,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -27045,7 +27045,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -27057,7 +27057,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ @@ -27864,7 +27864,7 @@ } }, { - "Name": "FeatureColumn", + "Name": "FeatureColumnName", "Type": "String", "Desc": "Column to use for features", "Aliases": [ @@ -27896,7 +27896,7 @@ } }, { - "Name": "LabelColumn", + "Name": "LabelColumnName", "Type": "String", "Desc": "Column to use for labels", "Aliases": [ @@ -27926,7 +27926,7 @@ } }, { - "Name": "WeightColumn", + "Name": "ExampleWeightColumnName", "Type": "String", "Desc": "Column to use for example weight", "Aliases": [ @@ -27938,7 +27938,7 @@ "Default": null }, { - "Name": "GroupIdColumn", + "Name": "RowGroupColumnName", "Type": "String", "Desc": "Column to use for example groupId", "Aliases": [ From cca1d13299b4f37913f9154e25528d5ddde6c59b Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Wed, 27 Feb 2019 12:32:11 -0800 Subject: [PATCH 10/11] fix tests --- .../UnitTests/TestEntryPoints.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs index 3a5ea2ce1e..3e20db828e 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs @@ -3435,7 +3435,7 @@ public void EntryPointPrepareLabelConvertPredictedLabel() 'Name': 'Transforms.LabelColumnKeyBooleanConverter', 'Inputs': {{ 'Data': '$data1', - 'LabelColumnName': 'Label' + 'LabelColumn': 'Label' }}, 'Outputs': {{ 'OutputData': '$data2' @@ -4005,8 +4005,8 @@ public void TestSimpleTrainExperiment() 'NumRocExamples': 100000, 'MaxAucExamples': -1, 'NumAuPrcExamples': 100000, - 'LabelColumnName': null, - 'ExampleWeightColumnName': null, + 'LabelColumn': null, + 'WeightColumn': null, 'ScoreColumn': null, 'StratColumn': null, 'Data': '$Var_be77f9c4e45c43b7a67984304c291bf5', @@ -4180,8 +4180,8 @@ public void TestCrossValidationMacro() 'StratificationColumn': null, 'NumFolds': 2, 'Kind': 'SignatureRegressorTrainer', - 'LabelColumnName': 'Label', - 'ExampleWeightColumnName': 'Weight1', + 'LabelColumn': 'Label', + 'WeightColumn': 'Weight1', 'GroupColumn': null, 'NameColumn': null }, @@ -4364,8 +4364,8 @@ public void TestCrossValidationMacroWithMultiClass() 'StratificationColumn': null, 'NumFolds': 2, 'Kind': 'SignatureMultiClassClassifierTrainer', - 'LabelColumnName': 'Label', - 'ExampleWeightColumnName': null, + 'LabelColumn': 'Label', + 'WeightColumn': null, 'GroupColumn': null, 'NameColumn': null }, @@ -4591,8 +4591,8 @@ public void TestCrossValidationMacroMultiClassWithWarnings() 'StratificationColumn': 'Strat', 'NumFolds': 2, 'Kind': 'SignatureMultiClassClassifierTrainer', - 'LabelColumnName': 'Label', - 'ExampleWeightColumnName': null, + 'LabelColumn': 'Label', + 'WeightColumn': null, 'GroupColumn': null, 'NameColumn': null }, @@ -4771,8 +4771,8 @@ public void TestCrossValidationMacroWithStratification() 'StratificationColumn': 'Strat', 'NumFolds': 2, 'Kind': 'SignatureBinaryClassifierTrainer', - 'LabelColumnName': 'Label', - 'ExampleWeightColumnName': null, + 'LabelColumn': 'Label', + 'WeightColumn': null, 'GroupColumn': null, 'NameColumn': null }, @@ -5066,8 +5066,8 @@ public void TestCrossValidationMacroWithNonDefaultNames() 'StratificationColumn': null, 'NumFolds': 2, 'Kind': 'SignatureRankerTrainer', - 'LabelColumnName': 'Label1', - 'ExampleWeightColumnName': null, + 'LabelColumn': 'Label1', + 'WeightColumn': null, 'GroupColumn': { 'Value': 'GroupId1', 'IsExplicit': true @@ -5291,8 +5291,8 @@ public void TestOvaMacro() 'NumTopClassesToOutput': 3, 'NumClassesConfusionMatrix': 10, 'OutputPerClassStatistics': false, - 'LabelColumnName': null, - 'ExampleWeightColumnName': null, + 'LabelColumn': null, + 'WeightColumn': null, 'ScoreColumn': null, 'StratColumn': null, 'Data': '$Var_5454fd8c353c40288dd8c2d104be788f', @@ -5461,8 +5461,8 @@ public void TestOvaMacroWithUncalibratedLearner() 'NumTopClassesToOutput': 3, 'NumClassesConfusionMatrix': 10, 'OutputPerClassStatistics': false, - 'LabelColumnName': null, - 'ExampleWeightColumnName': null, + 'LabelColumn': null, + 'WeightColumn': null, 'ScoreColumn': null, 'StratColumn': null, 'Data': '$Var_a20e37dc58d84bf5a1cb13ed13eae5ba', @@ -5570,7 +5570,7 @@ public void TestTensorFlowEntryPoint() 'OutputColumns': [ 'Softmax' ], - 'LabelColumnName': null, + 'LabelColumn': null, 'TensorFlowLabel': null, 'OptimizationOperation': null, 'LossOperation': null, From 0ff67feda38e3ca4a0278e7bcb3d9f6882a478c4 Mon Sep 17 00:00:00 2001 From: Gani Nazirov Date: Wed, 27 Feb 2019 13:44:33 -0800 Subject: [PATCH 11/11] fix test --- test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs index 3e20db828e..87e788c31f 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs @@ -1848,7 +1848,7 @@ public void EntryPointEvaluateRanking() 'Name': 'Transforms.LabelColumnKeyBooleanConverter', 'Inputs': { 'Data': '$output_data1', - 'LabelColumnName': 'Label', + 'LabelColumn': 'Label', 'TextKeyValues': false }, 'Outputs': {