Share via


ValueMappingEstimator<TKey,TValue> Class

Definition

Estimator for ValueMappingTransformer creating a key-value map using the pairs of values in the input data PrimitiveDataViewType

public sealed class ValueMappingEstimator<TKey,TValue> : Microsoft.ML.Transforms.ValueMappingEstimator
type ValueMappingEstimator<'Key, 'Value> = class
    inherit ValueMappingEstimator
Public NotInheritable Class ValueMappingEstimator(Of TKey, TValue)
Inherits ValueMappingEstimator

Type Parameters

TKey

Specifies the key type.

TValue

Specifies the value type.

Inheritance

Remarks

Estimator Characteristics

Does this estimator need to look at the data to train its parameters? No
Input column data type Vector or primitive numeric, boolean, text, System.DateTime and key type.
Output column data type Vector or primitive numeric, boolean, text, System.DateTime and key type.
Exportable to ONNX No

Given two sets of values, one serving as the key, and the other as the value of a Dictionary, the ValueMappingEstimator builds up this dictionary so that when given a specific key it will return a specific value.The ValueMappingEstimator supports keys and values of different System.Type to support different data types. Examples for using a ValueMappingEstimator are:

  • Converting a string value to a string value, this can be useful for grouping (i.e. 'cat', 'dog', 'horse' maps to 'mammals').
  • Converting a string value to a integer value (i.e. converting the text description like quality to an numeric where 'good' maps to 1, 'poor' maps to 0.
  • Converting a integer value to a string value and have the string value represented as a key type. (i.e. convert zip codes to a state string value, which will generate a unique integer value that can be used as a label.

Values can be repeated to allow for multiple keys to map to the same value, however keys can not be repeated. The mapping between keys and values can be specified either through lists, where the key list and value list must be the same size or can be done through an System.IDataView.

Check the See Also section for links to usage examples.

Methods

Fit(IDataView) (Inherited from TrivialEstimator<TTransformer>)
GetOutputSchema(SchemaShape)

Returns the SchemaShape of the schema which will be produced by the transformer. Used for schema propagation and verification in a pipeline.

(Inherited from ValueMappingEstimator)

Extension Methods

AppendCacheCheckpoint<TTrans>(IEstimator<TTrans>, IHostEnvironment)

Append a 'caching checkpoint' to the estimator chain. This will ensure that the downstream estimators will be trained against cached data. It is helpful to have a caching checkpoint before trainers that take multiple data passes.

WithOnFitDelegate<TTransformer>(IEstimator<TTransformer>, Action<TTransformer>)

Given an estimator, return a wrapping object that will call a delegate once Fit(IDataView) is called. It is often important for an estimator to return information about what was fit, which is why the Fit(IDataView) method returns a specifically typed object, rather than just a general ITransformer. However, at the same time, IEstimator<TTransformer> are often formed into pipelines with many objects, so we may need to build a chain of estimators via EstimatorChain<TLastTransformer> where the estimator for which we want to get the transformer is buried somewhere in this chain. For that scenario, we can through this method attach a delegate that will be called once fit is called.

Applies to

See also