Closed drake7707 closed 4 years ago
Hi Drake
It's in the order it read the classes into memory.
When you configure the pipeline try:
var dataProcessPipeline = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: "KeyColumn", inputColumnName: nameof(RecordFeatures.Label) ,keyOrdinality:ValueToKeyMappingEstimator.KeyOrdinality.ByValue);
Have a look at ValueToKeyMappingEstimator, has 2 parameters.
This is related to issue #3769
The predicted label of multi-class classifier is the ordinal of your index. For example, if it produces 0, it means the first label.
Well, not really, depends on the sort provided and the sort needs to be looked at as Option 1 it sorts based on the order the date was loaded Option 2 it sorts based on the ASCII alphabet
Both are not that help full if the label is a annotation where the values have meaning like rating as a miss is a miss based on a scale "Desaster","Really bad", "Bad", "Okey", "Good", "Really good", "Ausom".
When looking at the confusion matrix It would not be so bad when the scale tips to the neighbor, really bad if there is no visual pattern on the prediction. Please note that the Confusion Matrix is all about projecting patterns, hard to see them if it's "random" ordered
Thanks for the explanation, it's still pretty confusing (no pun intended) though.
If I understand it correctly, the Accuracy and LogLoss metrics are completely dependent on the order of the samples. I would expect that the order of the labels doesn't matter, and the metrics, which indicate the performance of the model after all would always be the same, regardless of the order of the samples in the test set.
When I changed my training/test set to get a better balance between the classes, it looked as if the model just didn't train at all, while in fact it performed better. It was just the metrics and confusion matrix that made it look that way. I got lucky and happened to notice the shift in the pattern in my confusion matrix and adjusted my set accordingly but this behaviour isn't at all intuitive to someone new to ML.NET, ergo why I opened this issue.
Yes, It's a bit vodoo at the moment, it was worse in the past and I opened quite a few tickets myself. I found that executing the model using the predict function and make my own statistics helps understanding me to the quality of my model much better, I can't reproduce the same metrics executing the rows as what evaluate function returns; same data different results.
I also noticed that the "predicted" multi-class not always correspond with the best prediction and that number predictions sometimes are off by a margin, I run a 2nd model against the prediction just to get the result "normalized".
When you look you'll notice that the code work well on the test samples, like the code is tuned to work on unit tests and not against live data. I have not noticed as good a score with production data using this framework. I also noted that it can't really deal with large data-sets, as soon as you go above say few 100GB the it just loops until you run out of patience.
You will find some nice samples in the source code of how to implement the models, documentation is getting better as well. Read through the posts here and you will find lots of solutions to the same issues that you will run-into.
Have a look at AutoML, give it your dataset, it will train several models and will generate the code after "tuning" it. At the moment it doesn't always pics the best model but that bug is being worked on already. I find that AutoML is a nice "bootstrap" and definitely gets you started.
@drake7707 I am assuming your query has been answered. I am closing the issue. Please reopen if necessary.
System information
Issue
Confusion matrix when I add the labels ascending (0 -> n) of the samples (e.g 0,1,2,3,4,0,1,2,3,4,...). This is the correct evaluation.
Now when I do OrderByDescending to reverse the labels and run it again, I get:
Confusion matrix when I reverse the labels (n -> 0) of the samples (e.g 4,3,2,1,0,4,3,2,1,0,...)
I think there is an expectation somewhere that the label == the label index.
Source code / logs