Skip to content

Conversation

@Omswastik-11
Copy link

@Omswastik-11 Omswastik-11 commented Nov 23, 2025

Summary

This PR adds integration for sktime time series regression, addressing . It introduces TSROptCV, enabling users to optimize sktime regressors using any Hyperactive optimizer (e.g., Random Search, Hill Climbing, Optuna TPE).


Key Changes

  • Added TSROptCV in _regression.py — a delegate regressor that wraps the Hyperactive optimization workflow.
  • Added SktimeRegressionExperiment in sktime_regression.py — an adapter connecting sktime’s evaluate() function to Hyperactive’s experiment interface.
  • Exported TSROptCV in __init__.py.
  • Added integration tests in test_sktime_estimators.py to ensure compatibility with the sktime estimator contract.
  • Minor update to _BaseGFOadapter to expose best_score_ for consistency with other integrations.

API Usage

import numpy as np
from sktime.datasets import load_unit_test
from sktime.regression.distance_based import KNeighborsTimeSeriesRegressor
from hyperactive.integrations.sktime import TSROptCV
from hyperactive.opt import RandomSearch

# 1. Load data
X_train, y_train = load_unit_test(split="train", return_X_y=True)
X_test, y_test = load_unit_test(split="test", return_X_y=True)

# 2. Define estimator and search space
estimator = KNeighborsTimeSeriesRegressor()
search_space = {
    "n_neighbors": list(range(1, 10)),
    "weights": ["uniform", "distance"],
}

# 3. Initialize TSROptCV with a Hyperactive optimizer
tsr_opt = TSROptCV(
    estimator=estimator,
    optimizer=RandomSearch(search_space, n_iter=10),
    cv=3,
    n_jobs=1,
)

# 4. Run optimization
tsr_opt.fit(X_train, y_train)

# 5. Check best results
print("Best score:", tsr_opt.best_score_)
print("Best params:", tsr_opt.best_params_)

# 6. Predict using the optimized model
y_pred = tsr_opt.predict(X_test)

Testing


Screenshot 2025-11-23 193751

Fixes


#196

@Omswastik-11 Omswastik-11 marked this pull request as draft November 23, 2025 15:28
@Omswastik-11 Omswastik-11 marked this pull request as ready for review November 23, 2025 16:18
@Omswastik-11 Omswastik-11 changed the title [ENH] Created Sktime regression interface with Hyperactive [ENH] Sktime regression integration Nov 23, 2025
@Omswastik-11 Omswastik-11 marked this pull request as draft November 27, 2025 12:59
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failures are due to lack of isolation of the imports in get_test_params - have a look how this is solved for the time series classification case.

@Omswastik-11 Omswastik-11 requested a review from fkiraly November 29, 2025 16:32
@Omswastik-11 Omswastik-11 marked this pull request as ready for review November 29, 2025 16:32
@Omswastik-11
Copy link
Author

Hi @fkiraly !! Is it looks fine now ?

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

Successfully merging this pull request may close these issues.

2 participants