Skip to main content

A hyperparameter optimization framework via optuna.

Project description

optuna-learn

Tuning hyper-parameters based on Optuna is as easy as using scikit-learn.

:hourglass_flowing_sand: Dependencies

optuna-learn requires:

  • python >= 3.6
  • scikit-learn
  • optuna

:zap: Quick Start

from lightgbm import LGBMClassifier
from optlearn.opt import OptunaSearch
from sklearn.datasets import load_iris
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

opt = OptunaSearch(
        model=LGBMClassifier,
        optimize_direction='minimize',
        params_dict={
            'n_estimators': ['categorical', 100, 200, 300, 500],
            'reg_alpha': ['float', 0.001, 10, False],
            'reg_lambda': ['float', 0.001, 100, False],
            'num_leaves': ['int', 2, 256],
        }
)

opt.fit(X_train, y_train)

y_pred = opt.predict(X_test)

accuracy_score(y_test, y_pred)
>>> 0.9967924528301886

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optuna-learn-0.1.0.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

optuna_learn-0.1.0-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page