rfflearn_logo

rfflearn.cpu.*_tuner

Hyperparameter tuners for ML models in RFFLearn. The hyperparameter tuning functions are prepared for each ML model. For example, rfflearn.cpu.RFFSVC_tuner tunes the hyperparameter of RFFSVC model. The functions in this module are just wrapper functions of optuna.study module. Optuna is well-designed and easy to use, so you can rewrite a code that is equivalent to the functions in rfflearn.tuner if you want to extend it.

def rfflearn.cpu.RFFRegressor_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None):
def rfflearn.cpu.ORFRegressor_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None):
def rfflearn.cpu.QRFRegressor_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None):
def rfflearn.cpu.RFFSVC_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None):
def rfflearn.cpu.ORFSVC_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None):
def rfflearn.cpu.QRFSVC_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None):
def rfflearn.cpu.RFFGPC_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None, range_std_error=None):
def rfflearn.cpu.ORFGPC_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None, range_std_error=None):
def rfflearn.cpu.QRFGPC_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None, range_std_error=None):
def rfflearn.cpu.RFFGPR_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None, range_std_error=None):
def rfflearn.cpu.ORFGPR_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None, range_std_error=None):
def rfflearn.cpu.QRFGPR_tuner(train_set, valid_set, range_dim_kernel=None, range_std_kernel=None, range_std_error=None):

Parameters:

train_set: tuple

A pair of training data and labels such as (Xs, ys).

valid_set: tuple

A pair of validation data and labels such as (Xs, ys).

range_dim_kernel: dict

Range of hyperparameter search for the RFF kernel dimension.

range_std_kernel: dict

Range of hyperparameter search for the standard deviation of the RFF kernel.

range_std_error: dict

Range of hyperparameter search for the measurement error.

Returns:

optuna.study.Study

Optimized study instance.

Minimal Example

>>> import numpy as np                                               # Import Numpy
>>> import rfflearn.cpu as rfflearn                                  # Import rfflearn
>>> X_train = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])         # Define input data for training
>>> y_train = np.array([1, 1, 2, 2])                                 # Define label data for training
>>> X_valid = np.array([[-0.8, -1]])                                 # Define input data for validation
>>> y_valid = np.array([1])                                          # Define label data for validation
>>> train_set = (X_train, y_train)                                   # Define traning set
>>> valid_set = (X_valid, y_valid)                                   # Define validation set
>>> study = rfflearn.RFFSVC_tuner(train_set, valid_set, n_trials=10) # Start hyperparameter tuning
>>> study.best_params
{'dim_kernel': 975, 'std_kernel': 0.05127523853510559}
>>> study.best_model
<rfflearn.cpu.rfflearn_cpu_svc.RFFSVC object at 0x7fa094509d00>