hosa.optimization.hosa.BaseHOSA

class hosa.optimization.hosa.BaseHOSA(x, y, model, n_outputs, parameters, tr, apply_rsv=True, validation_size=0.25, n_splits=10)[source]

Bases: object

Heuristic Oriented Search Algorithm (HOSA)

This class implments the HOSA. Following a heuristic search, the algorithm finetunes the most relevant models’ parameters. Thus, HOSA avoids testing every possible combination, and therefore, an exhaustive search.

Warning

This class should not be used directly. Use derived classes instead, i.e., HOSACNN or HOSARNN.

Parameters
  • x (numpy.ndarray) – Input data.

  • y (numpy.ndarray) – Target values (class labels in classification, real numbers in regression).

  • model (object) – Class of the object to be optimized. Available options are: RNNClassification, RNNRegression, CNNClassification and CNNRegression.

  • n_outputs (int) – Number of class labels in classification, or the number of numerical values to predict in regression.

  • parameters (dict) – Dictionary with parameters names (str) as keys and lists of parameter settings to try as values.

  • tr (float) – Minimum threshold of improvement of the performance metric.

  • apply_rsv (bool) – True if random sub-sampling validation should be used during the optimization procedure.

  • validation_size (float) – Proportion of the dataset to include in the validation split on the random sub-sampling validation. Ignored if ``apply_rsv = False``.

  • n_splits (int) – Number of splits used in the random sub-sampling validation. Ignored if ``apply_rsv = False``.

Methods

fit(**kwargs)

Optimize the model following the HOSA approach with all sets of parameters.

get_model()

Get the best model found.

get_params()

Get parameters for the best model found.

grid_search([n_kernels, ...])

Runs a grid search on the remaining moldel's parameters.

predict(x, **kwargs)

Predicts the target values using the input data in the best model found.

score(x, y, **kwargs)

Computes the performance metrics on the given input data and target values in the best model found.