-
Notifications
You must be signed in to change notification settings - Fork 0
bench: add auto feature engineering use-case report #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8e5d323
fix: harden source imports and fit_transform kwargs
thinkall 50b399c
feat: add leakage guard and time-aware prototype
thinkall 50957fa
feat: improve engine APIs and benchmark realism
thinkall db24392
docs: add relational example and branch summary
thinkall 9315422
bench: add auto feature engineering use-case report
thinkall c4a8a93
style: run pre-commit on benchmark script
thinkall a09dc98
fix: address benchmark and leakage review feedback
Copilot 4ddcce5
test: cover leakage column edge cases
Copilot e280cfc
refactor: simplify leakage target matching
Copilot 4dcdfe9
docs: clarify leakage target matching
Copilot f5e78a8
test: cover mixed leakage keyword columns
Copilot b1a3275
test: cover non-string leakage targets
Copilot d1e8924
refactor(bench): share split helper and document target_name
thinkall dd982a4
fix(benchmarks): add future annotations import to datasets module
thinkall e76d312
chore: remove PR_SUMMARY_feat_strengthen_core_api.md
thinkall cbf821d
fix(api,bench): harden sklearn cloning and benchmark tool calls
thinkall 939a6b5
fix(api,bench): validate set_params keys, regenerate use-case report
thinkall 47ff184
fix(sklearn_compat): reset fit state and make set_params atomic
thinkall 681841f
fix: clearer ValueErrors for non-string engine names and out-of-range…
thinkall bf6b8f9
fix: stricter empty/falsy handling for engines and target_name
thinkall 28345c0
fix(sklearn_compat): reject non-sequence engines/methods and widen ta…
thinkall 0e329f1
fix(validation): skip leakage check for columns whose label normalize…
thinkall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| """Shared split utilities for FeatCopilot benchmarks. | ||
|
|
||
| Centralizes the split policy so individual benchmark scripts share the same | ||
| realistic defaults: chronological splits for forecasting/timeseries tasks and | ||
| stratified random splits for classification tasks (when class counts allow). | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
| from sklearn.model_selection import train_test_split | ||
|
|
||
|
|
||
| def split_benchmark_data( | ||
| X: pd.DataFrame, | ||
| y: pd.Series, | ||
| task: str, | ||
| random_state: int, | ||
| test_size: float = 0.2, | ||
| ) -> tuple[np.ndarray, np.ndarray, pd.Series, pd.Series]: | ||
| """ | ||
| Split benchmark data with task-aware defaults. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : pandas.DataFrame | ||
| Feature matrix. Only its length is used; the function returns positional | ||
| indices (use ``X.iloc[train_idx]`` / ``X.iloc[test_idx]`` to materialize | ||
| the splits). | ||
| y : pandas.Series | ||
| Target values aligned with ``X``. | ||
| task : str | ||
| Task identifier. Substrings ``"forecast"`` / ``"timeseries"`` trigger a | ||
| chronological split; ``"classification"`` triggers a stratified split | ||
| when class counts allow it. Anything else falls back to a random split. | ||
| random_state : int | ||
| Random state for reproducible random splits. | ||
| test_size : float, default=0.2 | ||
| Fraction of rows held out for the test split. | ||
|
|
||
| Returns | ||
| ------- | ||
| train_idx : numpy.ndarray | ||
| Positional indices for the training rows. | ||
| test_idx : numpy.ndarray | ||
| Positional indices for the test rows. | ||
| y_train : pandas.Series | ||
| Target values for the training rows. | ||
| y_test : pandas.Series | ||
| Target values for the test rows. | ||
|
|
||
| Raises | ||
| ------ | ||
| ValueError | ||
| If ``test_size`` is not strictly between 0 and 1, or if the resulting | ||
| chronological split would leave either side empty (for example, a | ||
| very small dataset combined with an extreme ``test_size``). | ||
| """ | ||
| # Validate ``test_size`` up front so the chronological branch matches the | ||
| # behavior of ``sklearn.model_selection.train_test_split`` (which rejects | ||
| # ``test_size <= 0`` / ``>= 1``) instead of silently producing an empty | ||
| # or overlapping split. | ||
| if not (0 < test_size < 1): | ||
| raise ValueError(f"test_size must be a float strictly between 0 and 1; got {test_size!r}") | ||
|
|
||
| indices = np.arange(len(X)) | ||
|
|
||
| if "forecast" in task or "timeseries" in task: | ||
| split_idx = int(len(indices) * (1 - test_size)) | ||
| if split_idx <= 0 or split_idx >= len(indices): | ||
| raise ValueError( | ||
| "Chronological split would leave one side empty: " | ||
| f"len(X)={len(indices)}, test_size={test_size} -> split_idx={split_idx}. " | ||
| "Provide more rows or pick a different ``test_size``." | ||
| ) | ||
| train_idx = indices[:split_idx] | ||
| test_idx = indices[split_idx:] | ||
| y_train = y.iloc[train_idx] | ||
| y_test = y.iloc[test_idx] | ||
| return train_idx, test_idx, y_train, y_test | ||
|
|
||
| stratify = None | ||
| if "classification" in task: | ||
| try: | ||
| class_counts = pd.Series(y).value_counts(dropna=False) | ||
| if len(class_counts) > 1 and class_counts.min() >= 2: | ||
| stratify = y | ||
| except Exception: | ||
| stratify = None | ||
|
|
||
| train_idx, test_idx, y_train, y_test = train_test_split( | ||
| indices, | ||
| y, | ||
| test_size=test_size, | ||
| random_state=random_state, | ||
| stratify=stratify, | ||
| ) | ||
| return train_idx, test_idx, y_train, y_test | ||
|
|
||
|
|
||
| __all__ = ["split_benchmark_data"] | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Auto Feature Engineering Use-Case Benchmark | ||
|
|
||
| Compares a plain baseline with FeatCopilot and common automatic feature engineering tools on an interaction-heavy tabular classification task. | ||
|
|
||
| | Tool | Status | ROC-AUC | Feature Count | | ||
| |------|--------|---------|---------------| | ||
| | baseline | ok | 0.6330 | 9 | | ||
| | featcopilot | ok | 0.6328 | 11 | | ||
| | featuretools | ok | 0.6362 | 60 | | ||
| | autofeat | failed: check_array() got an unexpected keyword argument 'force_all_finite' | - | - | |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Use-Case Benchmarks | ||
|
|
||
| Targeted benchmarks for realistic feature-engineering scenarios. | ||
|
|
||
| ## Auto Feature Engineering | ||
|
|
||
| This benchmark compares: | ||
| - plain baseline | ||
| - FeatCopilot | ||
| - Featuretools (if installed) | ||
| - autofeat (if installed) | ||
|
|
||
| on an interaction-heavy tabular classification task where automatic feature engineering should matter. | ||
|
|
||
| ```bash | ||
| python -m benchmarks.use_cases.run_auto_feature_engineering_benchmark | ||
| ``` | ||
|
|
||
| Outputs: | ||
| - `AUTO_FEATURE_ENGINEERING_USE_CASE.md` |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.