Skip to content
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

the order of classification #341

Open
wangjiawen2013 opened this issue Apr 10, 2024 · 1 comment
Open

the order of classification #341

wangjiawen2013 opened this issue Apr 10, 2024 · 1 comment

Comments

@wangjiawen2013
Copy link

wangjiawen2013 commented Apr 10, 2024

Hi,
here is a confusion matrix getting from logistic regression:

classes negative positive
negative 295 0
positive 20 4

But I expect it is:

classes positive negative
positive 0 295
negative 4 20

How does linfa determine the order of the classification ? Does it affect the calculation of accuracy and decision ? which column is ground truth and which column is prediction ?

@wangjiawen2013
Copy link
Author

wangjiawen2013 commented Apr 11, 2024

Besides, I find that the confusion_matrix is not stable, it varies each run ! Is it caused by HashSet whose element is not in fixed order ?

pub trait Labels {
    type Elem: Label;

    fn label_count(&self) -> Vec<HashMap<Self::Elem, usize>>;

    fn label_set(&self) -> Vec<HashSet<Self::Elem>> {
        self.label_count()
            .iter()
            .map(|x| x.keys().cloned().collect::<HashSet<_>>())
            .collect()
    }

Run the program first time:
image

Run the program again:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant