I'm trying to use scikit-learn to plot a confusion matrix from raw data I have obtained (contains just predictions and ground truths).

The data contains a total of 4 classes: [0, 1, 2, 3]

One of the parameters of the confusion matrix is sample weight, and I noticed the shape has to be equal to the number of samples in the data.

Considering that the classes are imbalanced, and given the class ratio to all of: [0.5, 0.3. 0.15, 0.05], what would I need to pass to sample_weights to account for the class imbalance in evaluation, when I'm also trying to normalize the matrix?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.