Skip to content

Commit

Permalink
fix: make sampling more reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
yahiaelgamal committed Nov 23, 2023
1 parent 49cc545 commit 2997147
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/setfit/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def sample_dataset(dataset: Dataset, label_column: str = "label", num_samples: i
df = df.groupby(label_column)

# sample num_samples, or at least as much as possible
df = df.apply(lambda x: x.sample(min(num_samples, len(x))))
df = df.apply(lambda x: x.sample(min(num_samples, len(x)), random_state=seed))
df = df.reset_index(drop=True)

all_samples = Dataset.from_pandas(df, features=dataset.features)
Expand Down

0 comments on commit 2997147

Please sign in to comment.