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

Remove pickle from data formats, memmap for Tabular predictions #45

Merged
merged 7 commits into from
Oct 19, 2023

Conversation

geoalgo
Copy link
Collaborator

@geoalgo geoalgo commented Oct 17, 2023

WIP, the evaluation works from scratch and takes much less memory but I am still checking a few things.

A few notes:

  • the model predictions folder for each task contains now memmap predictions (.dat), labels (.csv.zip) and metadata.json
  • those files are downloaded as before by the context
  • there is now a file task_metrics.csv that contains all metrics for all tasks
  • tabular predictions can still be instantiated in memory by the same dictionary as before
  • I have not yet ported all the dense utils tests as some rely on gaps between validation/test which are not possible anymore
  • I have deleted all the pickle format files for predictions, groundtruth and metadata as we should avoid them

@geoalgo geoalgo requested a review from Innixma October 17, 2023 16:24
class EnsembleScorer:
def __init__(self,
zeroshot_pp: TabularModelPredictions | dict,
zeroshot_gt: Dict[str, Dict[int, Dict[str, Any]]],
tid_to_dataset_dict: dict,
Copy link
Collaborator

Choose a reason for hiding this comment

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

tid_to_dataset_dict should not be passed here. Instead, dataset should always be passed to evaluate_task as was done before. self.zeroshot_gt and self.zeroshot_pp should not use different keys to fetch the required information.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Previously EnsembleScorer had no concept of tid, which was the main point of the class, to remove the need to worry about tid and dataset conversions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For most of this, I can handle, but please align self.zeroshot_gt and self.zeroshot_pp to use the same key (probably dataset is best)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead, dataset should always be passed to evaluate_task as was done before. self.zeroshot_gt and self.zeroshot_pp should not use different keys to fetch the required information.

I did not change how evaluate_task is called, I just renamed dataset to tid as the field that was passed was effectively tid.

Previously zeroshot_pp had the dictionary internally (with a method rename_datasets) so the mapping is not added, it is just removed from zeroshot_pp.

I also think it would be good to use tid: int or dataset: str consistently when getting ground-truth, predictions etc but it is quite involved and I think it is probably out of scope for this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously EnsembleScorer had no concept of tid, which was the main point of the class, to remove the need to worry about tid and dataset conversions.

Reading this one, it seems that you mean that the name dataset should be kept, that one can be done but we have to reintroduce rename_dict or update the groundtruth class, I will take a look if it is possible without too much change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took a look and it is not straight-forward to unify dataset/tids in zeroshot_gt and zeroshot_pp. Of-course just unifying those two classes is trivial but the difficulty is with integrating all classes with a new naming. This is because right now, data is accessed in many different ways in different part of the code and classes (for instance tasks are addressed by a string f"{tid}_{fold}" by a float 123.4 where 123 is the task and 4 is the fold or by a tuple, by dataset or by tid).

This PR is already covering a lot by revamping all the pickles data structures and associated classes and updating all context files and I think it should be the content for another PR (which would for instance always address data with tid and fold by a tuple which would make the change much easier but would have to touch all the classes).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, I can try to see if it can be unified in a separate PR.

if rename_dict_inv:
dataset = rename_dict_inv.get(dataset, dataset)
return str(Path(output_dir) / f'{dataset}' / f'{fold}.pkl')
class TabularPredictionsMemmap(TabularModelPredictions):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please include a conversion method from TabularPredictionsMemmap to TabularPredictionsInMemory. It is easy to convert TabularPredictionsInMemory to TabularPredictionsMemmap, but the same is not currently true for the reverse.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I have added one.

Copy link
Collaborator

@Innixma Innixma left a comment

Choose a reason for hiding this comment

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

Added a few fixes, LGTM!

@Innixma Innixma merged commit 17a71f7 into main Oct 19, 2023
1 check passed
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