Skip to content

ValueMappingEstimator KeyType metadata maps to Key data and not to the Value data #2086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
singlis opened this issue Jan 9, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@singlis
Copy link
Member

singlis commented Jan 9, 2019

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
@singlis singlis self-assigned this Jan 9, 2019
@singlis singlis added the bug Something isn't working label Jan 9, 2019
singlis added a commit to singlis/machinelearning that referenced this issue Jan 9, 2019
ValueMappingEstimator used a key type resulted in the reverse key lookup
to fail. This was due to first the ValueMappingEstimator had an
incorrect metadata set for GetOutputSchema. Also the reverse lookup data
was set incorrectly and it would instead return the ValueMapping's Key
data instead of the Value data.

This also adds a test to verify the changes.

Fixes dotnet#2086
Fixes dotnet#2083
singlis added a commit to singlis/machinelearning that referenced this issue Jan 9, 2019
Values as KeyTypes:
1) The output schema for the Estimator did not contain the KeyType
information in the metadata.
2) The reverse lookup of the metadata had the incorrect value.

This now sets the correct metadata on the output schema and uses the
value data for the reverse lookup. A test was added to confirm the
changes using the KeyToValueMapping appended to a ValueMappingEstimator
for the reverse lookup.

Fixes dotnet#2086
Fixes dotnet#2083
singlis added a commit to singlis/machinelearning that referenced this issue Jan 9, 2019
Values as KeyTypes:
1) The output schema for the Estimator did not contain the KeyType
information in the metadata.
2) The reverse lookup of the metadata had the incorrect value.

This now sets the correct metadata on the output schema and uses the
value data for the reverse lookup. A test was added to confirm the
changes using the KeyToValueMapping appended to a ValueMappingEstimator
for the reverse lookup.

Fixes dotnet#2086
Fixes dotnet#2083
singlis added a commit that referenced this issue Jan 15, 2019
* The ValueMappingEstimator had a couple of issues when using setting the
Values as KeyTypes:
1) The output schema for the Estimator did not contain the KeyType
information in the metadata.
2) The reverse lookup of the metadata had the incorrect value.

This now sets the correct metadata on the output schema and uses the
value data for the reverse lookup. A test was added to confirm the
changes using the KeyToValueMapping appended to a ValueMappingEstimator
for the reverse lookup.

Fixes #2086
Fixes #2083
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant