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

Add loss value metric based on optimal performance definition #66

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jteijema
Copy link
Member

@jteijema jteijema commented Aug 27, 2024

A loss metric value based on the distance between the perfect recall curve and the actual recall curve.

output

@J535D165
Copy link
Member

J535D165 commented Sep 2, 2024

Failing tests seem unrelated, but do you have an idea?

@J535D165
Copy link
Member

J535D165 commented Sep 2, 2024

Linter fixed in main branch.

@jteijema
Copy link
Member Author

jteijema commented Sep 4, 2024

No, but I figured it wasn't on my branch indeed. Ill take another look!

@jteijema
Copy link
Member Author

jteijema commented Sep 4, 2024

The other tests are still failing. I think tf-keras needs to be a req for ASReview. But more importantly, why is it importing transformers when running our tests...

@jteijema
Copy link
Member Author

Tests are failing because of something fixed in #67 . Consider merging 67 and merging main into this branch to get the tests functional again.

@J535D165
Copy link
Member

Oke, remove the draft status of that pr.

def _loss_value(labels):
positive_doc_ratio = sum(labels) / len(labels)
triangle_before_perfect_recall = positive_doc_ratio * 0.5
aera_under_recall_curve = metrics.auc(*_recall_values(labels))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this not something like y*np.diff(x)?

In that case, we don't need the dependency (which is installed via asreview, but yeah).

@J535D165 J535D165 changed the title add loss value metric Add loss value metric based on optimal performance definition Sep 26, 2024
Comment on lines +188 to +190
def _loss(labels):
return _loss_value(labels)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the added value?

@J535D165
Copy link
Member

This PR needs a test and documentation. I'm not convinced this loss metric computes what's described in the PR description.

The following tests both fail:

def test_metric_loss_best():
    labels_best = [1, 1, 1, 0]
    loss = _loss(labels_best)

    assert_almost_equal(loss, 0)

def test_metric_loss_worst():
    labels_worst = [0, 0, 1, 1]
    loss = _loss(labels_worst)

    assert_almost_equal(loss, 1)

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

Successfully merging this pull request may close these issues.

2 participants