Skip to content

Commit

Permalink
improve testing, fix validate_ids invalid ticker return, add assertio…
Browse files Browse the repository at this point in the history
…ns to clean_predictions
  • Loading branch information
ndharasz committed Sep 10, 2024
1 parent cf72ba6 commit 628981c
Show file tree
Hide file tree
Showing 2 changed files with 239 additions and 80 deletions.
6 changes: 5 additions & 1 deletion numerai_tools/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def validate_ids(
len(live_sub) >= min_tickers
), f"Not enough stocks submitted. Are you using the latest live ids or live universe?"

invalid_tickers = list(index_sub.index.difference(live_sub.index))
invalid_tickers = list(set(index_sub[id_col]).difference(set(live_sub[id_col])))
return live_sub, invalid_tickers


Expand All @@ -138,6 +138,10 @@ def clean_predictions(
id_col: str - the column name of the ids
rank_and_fill: bool - whether to rank and fill NaNs with 0.5
"""
assert len(live_ids) > 0, "live_ids must not be empty"
assert live_ids.isna().sum() == 0, "live_ids must not contain NaNs"
assert len(predictions) > 0, "predictions must not be empty"

# drop null indices
predictions = predictions[~predictions[id_col].isna()]
predictions = (
Expand Down
Loading

0 comments on commit 628981c

Please sign in to comment.