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

analyze.ShowClassSplits returns empty data frame #147

Open
tarbaig opened this issue Aug 27, 2024 · 0 comments
Open

analyze.ShowClassSplits returns empty data frame #147

tarbaig opened this issue Aug 27, 2024 · 0 comments

Comments

@tarbaig
Copy link

tarbaig commented Aug 27, 2024

Description:

Using Analyze.ShowClassSplits on an object returned by the importer returns an empty dataframe.

Expected:

The returned frame should contain the proportion of the samples labeled train, test and validation by the splitter.

How to reproduce:

Assume "https://github.com/pylabelalpha/notebook/blob/main/BCCD_coco.zip?raw=true" is in the subdirectory 'data'

from pylabel import importer
from pathlib import Path
data_path = Path('data')
annotation_path = data_path / 'bccd' / 'BCCD_Dataset.json'
image_path = ""
dataset = importer.ImportCoco(path=str(annotation_path), path_to_images=str(image_path),name="BCCD_COCO")
dataset.splitter.GroupShuffleSplit(train_pct=.6,test_pct=.2,val_pct=.2)
assert not dataset.analyze.ShowClassSplits().empty

Suggested Fix

Looking into the code of the Analyze class it seems that the way the dataframes are created there does not work properly and the intermediat dataframes are already empty.

This can be fixed by creating those frames differntly e.g.

pylabel/pylabel/analyze.py

Lines 137 to 143 in 6e815ff

df_value_counts = pd.DataFrame(
ds.df["cat_name"].value_counts(normalize=normalize), columns=["cat_name"]
)
df_value_counts.index.name = "cat_name"
df_value_counts.columns = ["all"]

should be

df_value_counts = ds.df["cat_name"].value_counts(normalize=normalize).to_frame(name='all')

I can prepare a pull request if you like

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

No branches or pull requests

1 participant