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

Replace use of list for cached_data and subject_ids in pytorch dataset with polars objects #74

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions EventStream/data/pytorch_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,9 @@ def __init__(self, config: PytorchDatasetConfig, split: str):
self.cached_data = self.cached_data.sample(seed=self.config.train_subset_seed, **kwargs)

with self._time_as("convert_to_rows"):
self.subject_ids = self.cached_data["subject_id"].to_list()
self.subject_ids = self.cached_data["subject_id"]
self.cached_data = self.cached_data.drop("subject_id")
self.columns = self.cached_data.columns
self.cached_data = self.cached_data.rows()

@staticmethod
def _build_task_cached_df(task_df: pl.LazyFrame, cached_data: pl.LazyFrame) -> pl.LazyFrame:
Expand Down Expand Up @@ -479,7 +478,7 @@ def _seeded_getitem(self, idx: int) -> dict[str, list]:
output format.
"""

full_subj_data = {c: v for c, v in zip(self.columns, self.cached_data[idx])}
full_subj_data = {c: v for c, v in zip(self.columns, self.cached_data.row(idx))}
for k in ["static_indices", "static_measurement_indices"]:
if full_subj_data[k] is None:
full_subj_data[k] = []
Expand Down
Loading