Refactor dataset loaders into dedicated module#357
Closed
neuralsorcerer wants to merge 2 commits intofacebookresearch:mainfrom
Closed
Refactor dataset loaders into dedicated module#357neuralsorcerer wants to merge 2 commits intofacebookresearch:mainfrom
neuralsorcerer wants to merge 2 commits intofacebookresearch:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the simulated dataset loader functions into a dedicated balance.datasets.loading_data module while preserving the existing balance.datasets public API via re-exports.
Changes:
- Added
balance/datasets/loading_data.pycontainingload_sim_data,load_cbps_data, andload_data. - Updated
balance/datasets/__init__.pyto re-export the loader functions from the new module. - Added a changelog entry documenting the refactor.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| balance/datasets/loading_data.py | New dedicated module housing dataset loader implementations and their docstrings. |
| balance/datasets/init.py | Re-exports loaders to preserve balance.datasets.* public API. |
| CHANGELOG.md | Documents the refactor under “Code Quality & Refactoring”. |
Comments suppressed due to low confidence (4)
balance/datasets/loading_data.py:33
- The docstring says only
sample_dfhas ahappinesscolumn, but the implementation also setstarget_df["happiness"]. Please update the description to match the actual returned schema (or adjust the code if the intent is for only one dataframe to include the outcome).
Version 01 returns two dataframes containing the columns gender ("Male", "Female" and nan),
age_group ("18-24", "25-34", "35-44", "45+"), income (some numbers from a normal distribution), and id.
The sample_df also has a column called happiness with a value from 0 to 100 that depends on the covariates.
balance/datasets/loading_data.py:48
- The
Returns:section documentsTuple[pd.DataFrame, pd.DataFrame], but the function can return(None, None)for unsupported versions (and the type annotation already reflects that). Please update the docstring return type/description to include theNonecase (or raise an explicit error instead of returningNone).
Returns:
Tuple[pd.DataFrame, pd.DataFrame]: Two DataFrames containing simulated data for the target and sample of interest.
"""
balance/datasets/loading_data.py:153
- The
load_datadocstring says it returns two DataFrames, but the function returns(None, None)whensourceis unrecognized. Please align the documented return type/behavior with the implementation (e.g., document theNonecase or raise aValueErrorfor invalidsource).
Returns:
Tuple[pd.DataFrame, pd.DataFrame]: The first dataframe contains simulated data of the "target" and the second dataframe contains simulated data of the "sample".
"""
balance/datasets/loading_data.py:123
- The
load_cbps_datadocstring says "You can view the structure ... by looking at the example below", but no example is included. Please either add the example (the previous version had one) or remove this line to avoid misleading documentation.
"""Load simulated data for CBPS comparison with R.
The code in balance that implements CBPS attempts to mimic the code from the R package CBPS (https://cran.r-project.org/web/packages/CBPS/).
In the help page of the CBPS function in R (i.e.: `?CBPS::CBPS`) there is a simulated dataset that is used to showcase the CBPS function.
The output of that simulated dataset is saved in balance in order to allow for comparison of `balance` (Python) with `CBPS` (R).
You can view the structure of the simulated dataset by looking at the example below.
|
@talgalili has imported this pull request. If you are a Meta employee, you can view this in D95347392. |
|
@talgalili merged this pull request in c7b2e9f. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.