Closed
Description
Issue
Discovered while fixing #2083.
When creating a ValueMappingEstimator with KeyTypes as the values, the generated KeyType does not covert back to the original value. This is demonstrated when appending a KeyToValueTransform to retrieve the original values using the following code:
// Creating a list of keys that are based on the Education values
// These lists are created by hand for the demonstration, but the ValueMappingEstimator can take in any IEnumerables.
var educationKeys = new List<string>()
{
"0-5yrs",
"6-11yrs",
"12+yrs"
};
var educationValues = new List<string>()
{
"Cat1",
"Cat2",
"Cat3"
};
// Generate the estimator with the key type set as true. Even though are values are strings, this will
// create a key for each value. For this example, a KeyToValue Estimator is added to the ValueMapping Estimator to demonstrate the
// reverse lookup of the KeyType
var pipeline = new ValueMappingEstimator<string, string>(ml, educationKeys, educationValues, true, ("Education", "EducationKeyType"))
.Append(new KeyToValueMappingEstimator(ml, ("EducationKeyType", "EducationCategory")));
The expected results should be:
Age Education EducationCategory
26 0-5yrs Cat1
42 0-5yrs Cat1
39 12+yrs Cat3
34 0-5yrs Cat1
35 6-11yrs Cat2
The actual results are:
Age Education EducationCategory
26 0-5yrs 0-5yrs
42 0-5yrs 0-5yrs
39 12+yrs 12+yrs
34 0-5yrs 0-5yrs
35 6-11yrs 6-11yrs