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 diversity evaluation metrics #1416

Merged
merged 33 commits into from
Jun 11, 2021
Merged

Conversation

YanZhangADS
Copy link
Collaborator

@YanZhangADS YanZhangADS commented May 28, 2021

Description

Related Issues

Checklist:

  • I have followed the contribution guidelines and code style for this project.
  • I have added tests covering my contributions.
  • I have updated the documentation accordingly.
  • This PR is being made to staging branch and not to main branch.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Collaborator

@gramhagen gramhagen left a comment

Choose a reason for hiding this comment

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

this looks really great. i haven't had a chance to look closely at the notebook yet though

reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/diversity_evaluator.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@gramhagen gramhagen left a comment

Choose a reason for hiding this comment

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

this is looking great! i took a closer look at the notebook and focused most of the suggestions there, but caught a couple small items in the main and test files.

Copy link
Collaborator

@miguelgfierro miguelgfierro left a comment

Choose a reason for hiding this comment

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

Yan this is really good, I made some suggestions

reco_utils/evaluation/spark_diversity_evaluator.py Outdated Show resolved Hide resolved
reco_utils/evaluation/spark_diversity_evaluator.py Outdated Show resolved Hide resolved
Comment on lines 88 to 112
def test_catalog_coverage(evaluator, target_metrics):

c_coverage = evaluator.catalog_coverage()
assert c_coverage == target_metrics["c_coverage"]

@pytest.mark.spark
def test_distributional_coverage(evaluator, target_metrics):

d_coverage = evaluator.distributional_coverage()
assert d_coverage == target_metrics["d_coverage"]

@pytest.mark.spark
def test_item_novelty(evaluator, target_metrics):
actual = evaluator.item_novelty().toPandas()
assert_frame_equal(target_metrics["item_novelty"], actual, check_exact=False, check_less_precise=4)

@pytest.mark.spark
def test_user_novelty(evaluator, target_metrics):
actual = evaluator.user_novelty().toPandas()
assert_frame_equal(target_metrics["user_novelty"], actual, check_exact=False, check_less_precise=4)

@pytest.mark.spark
def test_novelty(evaluator, target_metrics):
actual = evaluator.novelty().toPandas()
assert_frame_equal(target_metrics["novelty"], actual, check_exact=False, check_less_precise=4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We also need to check the limits, this is very important to check that the formulas are correct. This would be check perfect novelty and non-novelty, perfect diversity and non-diversity, etc.

See example: https://github.com/microsoft/recommenders/blob/main/tests/unit/reco_utils/evaluation/test_spark_evaluation.py#L104

Copy link
Collaborator Author

@YanZhangADS YanZhangADS Jun 7, 2021

Choose a reason for hiding this comment

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

"check the limits" -- what is the precision you would recommend? I am comparing the number to the 4 positions after the decimal point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

4 position is great, we even have 2 position in some cases

@miguelgfierro
Copy link
Collaborator

I think we should add an entry about the diversity metrics in this notebook: https://github.com/microsoft/recommenders/blob/main/examples/03_evaluate/evaluation.ipynb
Basically do the same example as we did with rating and ranking, setting the limits, etc

Copy link
Collaborator

@gramhagen gramhagen left a comment

Choose a reason for hiding this comment

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

Great job!

@miguelgfierro miguelgfierro merged commit dd82287 into staging Jun 11, 2021
@miguelgfierro miguelgfierro deleted the zhangya_diversitymetrics branch June 11, 2021 22:09
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.

4 participants