Fix #341: Add support for string and categorical arrays in confusionmat #350
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I am Aaryan Johri, a first-year Computer Science student at VJTI, Mumbai.
This pull request addresses Issue #341 by extending the confusionmat function to support non-numeric data types, specifically string cell arrays and categorical arrays.
Technical Changes:
Added a new elseif conditional block (around Line 194) to detect isstring and iscategorical inputs.
Implemented a mapping logic using the union function to identify all unique classes across both actual and predicted sets.
Utilized find and indexing to populate the confusion matrix based on these identified labels, ensuring correct counts even for non-numeric data.
Verification & Testing:

Successfully verified the fix in GNU Octave using cell arrays of strings, producing the expected 2 X 2 matrix for unbalanced classes. Ran the internal test suite using test confusionmat to confirm that existing numeric functionality remains unaffected .I look forward to any feedback or suggestions for improvement.