diff --git a/src/Microsoft.ML.Data/Transforms/doc.xml b/src/Microsoft.ML.Data/Transforms/doc.xml index a3d4ba9f5e..13f108a107 100644 --- a/src/Microsoft.ML.Data/Transforms/doc.xml +++ b/src/Microsoft.ML.Data/Transforms/doc.xml @@ -28,7 +28,7 @@ The TextToKeyConverter transform builds up term vocabularies (dictionaries). - The TextToKey Converter and the are the two one primary mechanisms by which raw input is transformed into keys. + The TextToKeyConverter and the are the two one primary mechanisms by which raw input is transformed into keys. If multiple columns are used, each column builds/uses exactly one vocabulary. The output columns are KeyType-valued. The Key value is the one-based index of the item in the dictionary. @@ -49,6 +49,52 @@ + + + + Handle missing values by replacing them with either the default value or the indicated value. + + + This transform handles missing values in the input columns. For each input column, it creates an output column + where the missing values are replaced by one of these specified values: + + + The default value of the appropriate type. + + + The mean value of the appropriate type. + + + The max value of the appropriate type. + + + The min value of the appropriate type. + + + The last three work only for numeric/TimeSpan/DateTime kind columns. + + The output column can also optionally include an indicator vector for which slots were missing in the input column. + This can be done only when the indicator vector type can be converted to the input column type, i.e. only for numeric columns. + + + When computing the mean/max/min value, there is also an option to compute it over the whole column instead of per slot. + This option has a default value of true for variable length vectors, and false for known length vectors. + It can be changed to true for known length vectors, but it results in an error if changed to false for variable length vectors. + + + + + + + + + pipeline.Add(new MissingValueHandler("FeatureCol", "CleanFeatureCol") + { + ReplaceWith = NAHandleTransformReplacementKind.Mean + }); + + + diff --git a/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs b/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs index 0e5a4c1862..f404f3ae95 100644 --- a/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs +++ b/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs @@ -807,7 +807,7 @@ public static partial class TreeFeaturize Desc = TreeEnsembleFeaturizerTransform.TreeEnsembleSummary, UserName = TreeEnsembleFeaturizerTransform.UserName, ShortName = TreeEnsembleFeaturizerBindableMapper.LoadNameShort, - XmlInclude = new[] { @"" })] + XmlInclude = new[] { @"" })] public static CommonOutputs.TransformOutput Featurizer(IHostEnvironment env, TreeEnsembleFeaturizerTransform.ArgumentsForEntryPoint input) { Contracts.CheckValue(env, nameof(env)); diff --git a/src/Microsoft.ML.FastTree/doc.xml b/src/Microsoft.ML.FastTree/doc.xml index 8678654182..26d3c8c129 100644 --- a/src/Microsoft.ML.FastTree/doc.xml +++ b/src/Microsoft.ML.FastTree/doc.xml @@ -95,7 +95,7 @@ Generally, ensemble models provide better coverage and accuracy than single decision trees. Each tree in a decision forest outputs a Gaussian distribution. For more see: - + Wikipedia: Random forest Quantile regression forest From Stumps to Trees to Forests @@ -146,7 +146,7 @@ Trains a tree ensemble, or loads it from a file, then maps a numeric feature vector to three outputs: - + A vector containing the individual tree outputs of the tree ensemble. A vector indicating the leaves that the feature vector falls on in the tree ensemble. A vector indicating the paths that the feature vector falls on in the tree ensemble. @@ -157,28 +157,28 @@ In machine learning​ it is a pretty common and powerful approach to utilize the already trained model in the process of defining features. - One such example would be the use of model's scores as features to downstream models. For example, we might run clustering on the original features, + One such example would be the use of model's scores as features to downstream models. For example, we might run clustering on the original features, and use the cluster distances as the new feature set. - Instead of consuming the model's output, we could go deeper, and extract the 'intermediate outputs' that are used to produce the final score. + Instead of consuming the model's output, we could go deeper, and extract the 'intermediate outputs' that are used to produce the final score. There are a number of famous or popular examples of this technique: - - A deep neural net trained on the ImageNet dataset, with the last layer removed, is commonly used to compute the 'projection' of the image into the 'semantic feature space'. - It is observed that the Euclidean distance in this space often correlates with the 'semantic similarity': that is, all pictures of pizza are located close together, + + A deep neural net trained on the ImageNet dataset, with the last layer removed, is commonly used to compute the 'projection' of the image into the 'semantic feature space'. + It is observed that the Euclidean distance in this space often correlates with the 'semantic similarity': that is, all pictures of pizza are located close together, and far away from pictures of kittens. - A matrix factorization and/or LDA model is also often used to extract the 'latent topics' or 'latent features' associated with users and items. - The weights of the linear model are often used as a crude indicator of 'feature importance'. At the very minimum, the 0-weight features are not needed by the model, - and there's no reason to compute them. + A matrix factorization and/or LDA model is also often used to extract the 'latent topics' or 'latent features' associated with users and items. + The weights of the linear model are often used as a crude indicator of 'feature importance'. At the very minimum, the 0-weight features are not needed by the model, + and there's no reason to compute them. Tree featurizer uses the decision tree ensembles for feature engineering in the same fashion as above. - Let's assume that we've built a tree ensemble of 100 trees with 100 leaves each (it doesn't matter whether boosting was used or not in training). + Let's assume that we've built a tree ensemble of 100 trees with 100 leaves each (it doesn't matter whether boosting was used or not in training). If we associate each leaf of each tree with a sequential integer, we can, for every incoming example x, - produce an indicator vector L(x), where Li(x) = 1 if the example x 'falls' into the leaf #i, and 0 otherwise. + produce an indicator vector L(x), where Li(x) = 1 if the example x 'falls' into the leaf #i, and 0 otherwise. Thus, for every example x, we produce a 10000-valued vector L, with exactly 100 1s and the rest zeroes. - This 'leaf indicator' vector can be considered the ensemble-induced 'footprint' of the example. - The 'distance' between two examples in the L-space is actually a Hamming distance, and is equal to the number of trees that do not distinguish the two examples. + This 'leaf indicator' vector can be considered the ensemble-induced 'footprint' of the example. + The 'distance' between two examples in the L-space is actually a Hamming distance, and is equal to the number of trees that do not distinguish the two examples. We could repeat the same thought process for the non-leaf, or internal, nodes of the trees (we know that each tree has exactly 99 of them in our 100-leaf example), - and produce another indicator vector, N (size 9900), for each example, indicating the 'trajectory' of each example through each of the trees. - The distance in the combined 19900-dimensional LN-space will be equal to the number of 'decisions' in all trees that 'agree' on the given pair of examples. + and produce another indicator vector, N (size 9900), for each example, indicating the 'trajectory' of each example through each of the trees. + The distance in the combined 19900-dimensional LN-space will be equal to the number of 'decisions' in all trees that 'agree' on the given pair of examples. The TreeLeafFeaturizer is also producing the third vector, T, which is defined as Ti(x) = output of tree #i on example x. diff --git a/src/Microsoft.ML.KMeansClustering/doc.xml b/src/Microsoft.ML.KMeansClustering/doc.xml index a1590595dc..b4318de334 100644 --- a/src/Microsoft.ML.KMeansClustering/doc.xml +++ b/src/Microsoft.ML.KMeansClustering/doc.xml @@ -13,7 +13,7 @@ YYK-Means observes that there is a lot of redundancy across iterations in the KMeans algorithms and most points do not change their clusters during an iteration. It uses various bounding techniques to identify this redundancy and eliminate many distance computations and optimize centroid computations. For more information on K-means, and K-means++ see: - + K-means K-means++ diff --git a/src/Microsoft.ML.PCA/doc.xml b/src/Microsoft.ML.PCA/doc.xml index c4f0be7758..5054950c2d 100644 --- a/src/Microsoft.ML.PCA/doc.xml +++ b/src/Microsoft.ML.PCA/doc.xml @@ -11,7 +11,7 @@ Its training is done using the technique described in the paper: Combining Structured and Unstructured Randomness in Large Scale PCA, and the paper Finding Structure with Randomness: Probabilistic Algorithms for Constructing Approximate Matrix Decompositions For more information, see also: - + Randomized Methods for Computing the Singular Value Decomposition (SVD) of very large matrices diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/doc.xml b/src/Microsoft.ML.StandardLearners/FactorizationMachine/doc.xml index f18bf60990..bdcb973439 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/doc.xml +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/doc.xml @@ -15,14 +15,14 @@ See references below for more details. This trainer is essentially faster the one introduced in [2] because of some implemtation tricks[3]. - + - [1] Field-aware Factorization Machines for CTR Prediction + Field-aware Factorization Machines for CTR Prediction - [2] Adaptive Subgradient Methods for Online Learning and Stochastic Optimization + Adaptive Subgradient Methods for Online Learning and Stochastic Optimization - [3] An Improved Stochastic Gradient Method for Training Large-scale Field-aware Factorization Machine. + An Improved Stochastic Gradient Method for Training Large-scale Field-aware Factorization Machine. diff --git a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs index 0a73d55395..8c96ee1e0b 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs @@ -123,8 +123,8 @@ public override MultiClassNaiveBayesPredictor Train(TrainContext context) Desc = "Train a MultiClassNaiveBayesTrainer.", UserName = UserName, ShortName = ShortName, - XmlInclude = new[] { @"", - @"" })] + XmlInclude = new[] { @"", + @"" })] public static CommonOutputs.MulticlassClassificationOutput TrainMultiClassNaiveBayesTrainer(IHostEnvironment env, Arguments input) { Contracts.CheckValue(env, nameof(env)); diff --git a/src/Microsoft.ML.StandardLearners/Standard/Online/doc.xml b/src/Microsoft.ML.StandardLearners/Standard/Online/doc.xml index 0ace721221..2ad6e77aa0 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/Online/doc.xml +++ b/src/Microsoft.ML.StandardLearners/Standard/Online/doc.xml @@ -13,8 +13,8 @@ and an option to update the weight vector using the average of the vectors seen over time (averaged argument is set to True by default). - - + + new OnlineGradientDescentRegressor { diff --git a/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/doc.xml b/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/doc.xml index ec14c9446b..975f1eb2ff 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/doc.xml +++ b/src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/doc.xml @@ -12,8 +12,8 @@ Assuming that the dependent variable follows a Poisson distribution, the parameters of the regressor can be estimated by maximizing the likelihood of the obtained observations. - - + + new PoissonRegressor { diff --git a/src/Microsoft.ML.StandardLearners/Standard/doc.xml b/src/Microsoft.ML.StandardLearners/Standard/doc.xml index a704827b88..eb87605232 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/doc.xml +++ b/src/Microsoft.ML.StandardLearners/Standard/doc.xml @@ -22,7 +22,7 @@ In general, the larger the 'L2Const', the faster SDCA converges. For more information, see also: - + Scaling Up Stochastic Dual Coordinate Ascent. diff --git a/src/Microsoft.ML.Transforms/EntryPoints/SelectFeatures.cs b/src/Microsoft.ML.Transforms/EntryPoints/SelectFeatures.cs index c3ab4ea5e0..5733f84b6b 100644 --- a/src/Microsoft.ML.Transforms/EntryPoints/SelectFeatures.cs +++ b/src/Microsoft.ML.Transforms/EntryPoints/SelectFeatures.cs @@ -14,8 +14,8 @@ public static class SelectFeatures [TlcModule.EntryPoint(Name = "Transforms.FeatureSelectorByCount", Desc = CountFeatureSelectionTransform.Summary, UserName = CountFeatureSelectionTransform.UserName, - XmlInclude = new[] { @"", - @""})] + XmlInclude = new[] { @"", + @""})] public static CommonOutputs.TransformOutput CountSelect(IHostEnvironment env, CountFeatureSelectionTransform.Arguments input) { Contracts.CheckValue(env, nameof(env)); @@ -31,8 +31,8 @@ public static CommonOutputs.TransformOutput CountSelect(IHostEnvironment env, Co Desc = MutualInformationFeatureSelectionTransform.Summary, UserName = MutualInformationFeatureSelectionTransform.UserName, ShortName = MutualInformationFeatureSelectionTransform.ShortName, - XmlInclude = new[] { @"", - @""})] + XmlInclude = new[] { @"", + @""})] public static CommonOutputs.TransformOutput MutualInformationSelect(IHostEnvironment env, MutualInformationFeatureSelectionTransform.Arguments input) { Contracts.CheckValue(env, nameof(env)); diff --git a/src/Microsoft.ML.Transforms/MutualInformationFeatureSelection.cs b/src/Microsoft.ML.Transforms/MutualInformationFeatureSelection.cs index 55330cb6fb..0af833a046 100644 --- a/src/Microsoft.ML.Transforms/MutualInformationFeatureSelection.cs +++ b/src/Microsoft.ML.Transforms/MutualInformationFeatureSelection.cs @@ -21,7 +21,7 @@ namespace Microsoft.ML.Runtime.Data { - /// + /// public static class MutualInformationFeatureSelectionTransform { public const string Summary = diff --git a/src/Microsoft.ML.Transforms/doc.xml b/src/Microsoft.ML.Transforms/doc.xml index cb6ef6af25..63d2765afc 100644 --- a/src/Microsoft.ML.Transforms/doc.xml +++ b/src/Microsoft.ML.Transforms/doc.xml @@ -7,8 +7,7 @@ Encodes the categorical variable with hash-based encoding. - CategoricalHashOneHotVectorizer converts a categorical value into an indicator array by hashing the - value and using the hash as an index in the bag. + CategoricalHashOneHotVectorizer converts a categorical value into an indicator array by hashing the value and using the hash as an index in the bag. If the input column is a vector, a single indicator bag is returned for it. @@ -33,16 +32,16 @@ The CategoricalOneHotVectorizer transform passes through a data set, operating on text columns, to build a dictionary of categories. For each row, the entire text string appearing in the input column is defined as a category. - The output of this transform is an indicator vector. + The output of this transform is an indicator vector. Each slot in this vector corresponds to a category in the dictionary, so its length is the size of the built dictionary. - The CategoricalOneHotVectorizer can be applied to one or more columns, in which case it builds and uses a separate dictionary + The CategoricalOneHotVectorizer can be applied to one or more columns, in which case it builds and uses a separate dictionary for each column that it is applied to. - The produces integer values and columns. + The produces integer values and KeyType columns. The Key value is the one-based index of the slot set in the Ind/Bag options. If the Key option is not found, it is assigned the value zero. - In the , options are not found, they result in an all zero bit vector. - and differ simply in how the bit-vectors generated from individual slots are aggregated: + In the , options are not found, they result in an all zero bit vector. + and differ simply in how the bit-vectors generated from individual slots are aggregated: for Ind they are concatenated and for Bag they are added. When the source column is a singleton, the Ind and Bag options are identical. @@ -117,8 +116,7 @@ Creates a new column with the specified type and default values. - If the user wish to create additional columns with a particular type and default values, - or replicated the values from one column to another, changing their type, they can do so using this transform. + If the user wish to create additional columns with a particular type and default values, or replicated the values from one column to another, changing their type, they can do so using this transform. This transform can be used as a workaround to create a Label column after deserializing a model, for prediction. Some transforms in the serialized model operate on the Label column, and would throw errors during prediction if such a column is not found. @@ -206,53 +204,7 @@ - - - - Handle missing values by replacing them with either the default value or the indicated value. - - - This transform handles missing values in the input columns. For each input column, it creates an output column - where the missing values are replaced by one of these specified values: - - - The default value of the appropriate type. - - - The mean value of the appropriate type. - - - The max value of the appropriate type. - - - The min value of the appropriate type. - - - The last three work only for numeric/TimeSpan/DateTime kind columns. - - The output column can also optionally include an indicator vector for which slots were missing in the input column. - This can be done only when the indicator vector type can be converted to the input column type, i.e. only for numeric columns. - - - When computing the mean/max/min value, there is also an option to compute it over the whole column instead of per slot. - This option has a default value of true for variable length vectors, and false for known length vectors. - It can be changed to true for known length vectors, but it results in an error if changed to false for variable length vectors. - - - - - - - - - pipeline.Add(new MissingValueHandler("FeatureCol", "CleanFeatureCol") - { - ReplaceWith = NAHandleTransformReplacementKind.Mean - }); - - - - + The LpNormalizer transforms, normalizes vectors (rows) individually by rescaling them to unit norm (L2, L1 or LInf). @@ -325,8 +277,8 @@ be ignored, and the missing slots will be 'padded' with default values. - All metadata is preserved for the retained columns. For 'unrolled' columns, all known metadata - except slot names is preserved. + All metadata are preserved for the retained columns. For 'unrolled' columns, all known metadata + except slot names are preserved. diff --git a/src/Microsoft.ML/CSharpApi.cs b/src/Microsoft.ML/CSharpApi.cs index b2181fb256..3ac9a2acfb 100644 --- a/src/Microsoft.ML/CSharpApi.cs +++ b/src/Microsoft.ML/CSharpApi.cs @@ -3080,7 +3080,7 @@ public sealed partial class OneVersusAllMacroSubGraphOutput } - /// + /// public sealed partial class OneVersusAll : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithWeight, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithLabel, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInput, Microsoft.ML.ILearningPipelineItem { @@ -8601,8 +8601,8 @@ public LogisticRegressionClassifierPipelineStep(Output output) namespace Trainers { - /// - /// + /// + /// public sealed partial class NaiveBayesClassifier : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithLabel, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInput, Microsoft.ML.ILearningPipelineItem { @@ -11417,8 +11417,8 @@ public FeatureCombinerPipelineStep(Output output) namespace Transforms { - /// - /// + /// + /// public sealed partial class FeatureSelectorByCount : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITransformInput, Microsoft.ML.ILearningPipelineItem { @@ -11486,8 +11486,8 @@ public FeatureSelectorByCountPipelineStep(Output output) namespace Transforms { - /// - /// + /// + /// public sealed partial class FeatureSelectorByMutualInformation : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITransformInput, Microsoft.ML.ILearningPipelineItem { @@ -15329,7 +15329,7 @@ public sealed class Output namespace Transforms { - /// + /// public sealed partial class TreeLeafFeaturizer : Microsoft.ML.Runtime.EntryPoints.CommonInputs.IFeaturizerInput, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITransformInput, Microsoft.ML.ILearningPipelineItem { diff --git a/src/Microsoft.ML/Runtime/EntryPoints/OneVersusAllMacro.cs b/src/Microsoft.ML/Runtime/EntryPoints/OneVersusAllMacro.cs index 05688cd2af..3da05f1fbf 100644 --- a/src/Microsoft.ML/Runtime/EntryPoints/OneVersusAllMacro.cs +++ b/src/Microsoft.ML/Runtime/EntryPoints/OneVersusAllMacro.cs @@ -136,7 +136,7 @@ private static int GetNumberOfClasses(IHostEnvironment env, Arguments input, out [TlcModule.EntryPoint(Desc = "One-vs-All macro (OVA)", Name = "Models.OneVersusAll", - XmlInclude = new[] { @"" })] + XmlInclude = new[] { @"" })] public static CommonOutputs.MacroOutput OneVersusAll( IHostEnvironment env, Arguments input,