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

Feature: cross validate timings #233

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

Conversation

alekseykalyagin
Copy link

@alekseykalyagin alekseykalyagin commented Dec 12, 2024

Description

Closes issue #138

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Optimization

How Has This Been Tested?

Before submitting a PR, please check yourself against the following list. It would save us quite a lot of time.

  • Have you read the contribution guide?
  • Have you updated the relevant docstrings? We're using Numpy format, please double-check yourself
  • Does your change require any new tests?
  • Have you updated the changelog file?

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (9b3992e) to head (e474430).
Report is 86 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main      #233     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files           45        59     +14     
  Lines         2242      3893   +1651     
===========================================
+ Hits          2242      3893   +1651     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

rectools/model_selection/cross_validate.py Outdated Show resolved Hide resolved
rectools/model_selection/cross_validate.py Outdated Show resolved Hide resolved
rectools/model_selection/cross_validate.py Outdated Show resolved Hide resolved

if compute_timings:
for data in actual["metrics"]:
assert len(expected_keys.intersection(set(data.keys()))) == 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are checking only keys intersection because we have very differing timings for each run? If this is the case, let's just round the actual results to some reasonable number. And check values.
Or check that these values are less then some treshold.

Also we need to check that we didn't mess metrics results.
So we need to check all of the values like you do below for case when timings are not needed. (but as I wrote in another place, you don't need to check compute_timings=False scenario in this test)

Copy link
Author

Choose a reason for hiding this comment

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

done, chose threshold = 0.5

if timings is not None:
start_time = time.time()
yield
timings[label] = round(time.time() - start_time, 2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we needed to round not in the actual code but in the tests below. we are adding rounding just to pass the tests. so it shouldn't affect the actual code in framework.
let's round to 5 digits here

"precision@2": 0.375,
"recall@1": 0.5,
"intersection_popular": 0.75,
"fit_time": 0.0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's drop timings from expected dicts.
and keep thresholds comparison.
just pop timings from the actual dict

"ref_models,validate_ref_models,expected_metrics,compute_timings",
(
(
["popular"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's keep only ["popular"] and not put ref_models in parametrize.
let's iterate over validate_ref_models and compute_timings . only 4 test cases are needed

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