Skip to content

Commit

Permalink
Update core.py
Browse files Browse the repository at this point in the history
Allow user to set `batch_size` for HF dataset map
  • Loading branch information
Miking98 authored Apr 9, 2024
1 parent ecc2a0c commit a3e43c1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/femr/featurizers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def preprocess_featurizers(
index: femr.index.PatientIndex,
labels: List[meds.Label],
num_proc: int = 1,
batch_size: int = 1000,
) -> None:
"""Preprocess `self.featurizers` on the provided set of labels."""

Expand All @@ -264,7 +265,7 @@ def preprocess_featurizers(
dataset,
functools.partial(_preprocess_map_func, label_map=label_map, featurizers=self.featurizers),
_preprocess_agg_func,
batch_size=1_000,
batch_size=batch_size,
num_proc=num_proc,
)

Expand All @@ -279,6 +280,7 @@ def featurize(
index: femr.index.PatientIndex,
labels: List[meds.Label],
num_proc: int = 1,
batch_size: int = 1000,
) -> Mapping[str, np.ndarray]:
"""
Apply a list of Featurizers (in sequence) to obtain a feature matrix for each Label for each patient.
Expand Down Expand Up @@ -306,7 +308,7 @@ def featurize(
dataset,
functools.partial(_features_map_func, label_map=label_map, featurizers=self.featurizers),
_features_agg_func,
batch_size=1_000,
batch_size=batch_size,
num_proc=num_proc,
)

Expand Down

0 comments on commit a3e43c1

Please sign in to comment.