Skip to content
Merged
Show file tree
Hide file tree
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 Mar 17, 2026
50b399c
feat: add leakage guard and time-aware prototype
thinkall Mar 17, 2026
50957fa
feat: improve engine APIs and benchmark realism
thinkall Mar 17, 2026
db24392
docs: add relational example and branch summary
thinkall Mar 17, 2026
9315422
bench: add auto feature engineering use-case report
thinkall Mar 18, 2026
c4a8a93
style: run pre-commit on benchmark script
thinkall Mar 18, 2026
a09dc98
fix: address benchmark and leakage review feedback
Copilot Apr 28, 2026
4ddcce5
test: cover leakage column edge cases
Copilot Apr 28, 2026
e280cfc
refactor: simplify leakage target matching
Copilot Apr 28, 2026
4dcdfe9
docs: clarify leakage target matching
Copilot Apr 28, 2026
f5e78a8
test: cover mixed leakage keyword columns
Copilot Apr 28, 2026
b1a3275
test: cover non-string leakage targets
Copilot Apr 28, 2026
d1e8924
refactor(bench): share split helper and document target_name
thinkall Apr 29, 2026
dd982a4
fix(benchmarks): add future annotations import to datasets module
thinkall Apr 30, 2026
e76d312
chore: remove PR_SUMMARY_feat_strengthen_core_api.md
thinkall Apr 30, 2026
cbf821d
fix(api,bench): harden sklearn cloning and benchmark tool calls
thinkall Apr 30, 2026
939a6b5
fix(api,bench): validate set_params keys, regenerate use-case report
thinkall Apr 30, 2026
47ff184
fix(sklearn_compat): reset fit state and make set_params atomic
thinkall Apr 30, 2026
681841f
fix: clearer ValueErrors for non-string engine names and out-of-range…
thinkall Apr 30, 2026
bf6b8f9
fix: stricter empty/falsy handling for engines and target_name
thinkall Apr 30, 2026
28345c0
fix(sklearn_compat): reject non-sequence engines/methods and widen ta…
thinkall Apr 30, 2026
0e329f1
fix(validation): skip leakage check for columns whose label normalize…
thinkall Apr 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/compare_tools/run_fe_tools_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import pandas as pd
from packaging.version import Version
from sklearn.metrics import accuracy_score, f1_score, mean_squared_error, r2_score, roc_auc_score
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder

from benchmarks.datasets import (
Expand All @@ -61,12 +60,14 @@
sanitize_feature_frames,
save_feature_cache,
)
from benchmarks.splits import split_benchmark_data
from featcopilot.utils.logger import get_logger # noqa: E402

logger = get_logger(__name__)

warnings.filterwarnings("ignore")


# Default configuration
QUICK_DATASETS = [
# Interaction-heavy synthetic (FeatCopilot creates valuable polynomial features)
Expand Down Expand Up @@ -843,8 +844,7 @@ def run_single_benchmark(
X_encoded[col] = le.fit_transform(X_encoded[col].astype(str))

# Split data (keep raw and encoded in sync)
indices = np.arange(len(X_encoded))
train_idx, test_idx, y_train, y_test = train_test_split(indices, y, test_size=0.2, random_state=random_state)
train_idx, test_idx, y_train, y_test = split_benchmark_data(X_encoded, y, task, random_state)
X_train_encoded = X_encoded.iloc[train_idx]
X_test_encoded = X_encoded.iloc[test_idx]
X_train_raw = X.iloc[train_idx]
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
time series datasets, and text/semantic datasets for comprehensive benchmarking.
"""

from __future__ import annotations

import numpy as np
import pandas as pd

Expand Down
102 changes: 102 additions & 0 deletions benchmarks/splits.py
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
Comment thread
thinkall marked this conversation as resolved.

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"]
10 changes: 10 additions & 0 deletions benchmarks/use_cases/AUTO_FEATURE_ENGINEERING_USE_CASE.md
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' | - | - |
20 changes: 20 additions & 0 deletions benchmarks/use_cases/README.md
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`
Loading
Loading