Machine Learning

This module contains Machine Learning tools.

Created on Wed Sep 8 00:00:00 2021

@author: Jose Manuel Tapia Avitia, e-mail: josetapia@exatec.tec.mx

This module provides Machine Learning utilities that can power a neural-network-based hyper-heuristic. It wraps TensorFlow models and includes data-processing pipelines for operator-sequence prediction.

Note

This module requires TensorFlow. Install it with pip install customhys[ml].

Key classes:

  • DatasetSequences β€” converts raw operator sequences and fitness values into training samples suitable for supervised learning.

  • ModelPredictor β€” a configurable feed-forward neural network for predicting the next operator in a sequence.

Quick usage:

from customhys.machine_learning import DatasetSequences, ModelPredictor

ds = DatasetSequences(sequences, fitnesses, num_operators=13)
model = ModelPredictor(num_operators=13)
model.train(ds)
customhys.machine_learning.obtain_sample_weight(sample_fitness, fitness_to_weight='rank')[source]

Using decreasing functions to give more priority to samples with less fitness :param list sample_fitness: The fitness associated value for each sample :param str fitness_to_weight: Specify which function use to convert fitness to weight :return: An array that associates a weight to each sample

class customhys.machine_learning.DatasetSequences(sequences, fitnesses, num_operators=None, fitness_to_weight=None)[source]

Bases: object

__init__(sequences, fitnesses, num_operators=None, fitness_to_weight=None)[source]

Pre-process sequences to generate training data for HHNN

apply_one_hot_encoding(num_operators)[source]

One-Hot encode the output of the training data

obtain_dataset()[source]

Retrieve the pre-processed data

customhys.machine_learning.retrieve_model_info(params)[source]
class customhys.machine_learning.Encoder(params)[source]

Bases: object

encode(sequence)[source]
class customhys.machine_learning.ModelPredictorKeras(params)[source]

Bases: object

fit(X, y, epochs=100, sample_weight=None, verbose=False, early_stopping_params=None, verbose_statistics=False)[source]
predict(sequence)[source]
load(model_path=None)[source]
save(model_path=None)[source]
customhys.machine_learning.ModelPredictor(params)[source]