dotnet / dotnet/machinelearning-samples
The Iris classification sample way of reusing the "Label" column is confusing
- Dominant language
- PowerShell
- Stars
- 4.7k
- Forks
- 2.7k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 1
Description
As mentioned by this ML.NET user, the way the [Iris Multiclassification sample](https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started/MulticlassClassification_Iris) reuses the "Label" column is confusing:
https://github.com/dotnet/machinelearning/issues/5264#issuecomment-652487403.
The problem is that in the sample, we have this:
```C#
.Append(mlContext.Transforms.Conversion.MapKeyToValue(outputColumnName: nameof(IrisData.Label) , inputColumnName: "KeyColumn"));
```
Which the user interpreted that it was mapping the result of the prediction to the `Label` field.
What that step is doing is to actually map the key version of `Label` back to the original value of `Label` itself. Still, I don't know why this step is necessary, since the Label column itself is never modified (the MapValueToKey used at the beginning of the pipeline is actually mapping the Label column into a new KeyColumn, so no need to map back those values).
The lack of a `MapKeyToValue` that actually mapped back the values of "PredictedLabel" was what confused the user.
Furthermore, I also find strange that later when [consuming the model](https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started/MulticlassClassification_Iris#4-consume-model) the approach to get the values for the key "PredictedLabel" column is to actually get the annotations. Which is somewhat a weird approach, since I'd find using a `MapKeyToValue` to be more user-friendly.
I guess a closer look to this is needed to determine if there's a reason behind those decisions. But at first look it seems that they're unnecessary, and it would be less confusing for users if we get rid of them. Thanks 😄
Contributor guide
Assessment
This issue has not been assessed yet.