Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions openavmkit/tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,16 @@ def _catboost_rolling_origin_cv(


def _lightgbm_rolling_origin_cv(X, y, params, n_splits=5, random_state=42, cat_vars=None):
n_samples = len(X)
n_splits = min(n_splits, n_samples)
if n_splits < 2:
import warnings
warnings.warn(
f"Not enough samples ({n_samples}) for cross-validation with n_splits={n_splits}. "
"Returning penalty MAPE of 1.0.",
UserWarning,
)
return 1.0
kf = KFold(n_splits=n_splits, shuffle=True, random_state=random_state)
mape_scores = []

Expand Down
3 changes: 3 additions & 0 deletions openavmkit/utilities/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ def calc_correlations(

score = strength * clarity * clarity

# Guard against all-NA scores (too few samples to compute correlations)
if score.isna().all():
break
min_score_idx = score.idxmin()
try:
min_score = score[min_score_idx]
Expand Down
Loading