Auxiliar functions for testing

In order to modularize and make easier the testing of the networks, functions have been generalized and grouped in this file. Many of those functions are for loading the datasets that are also in this library, the rest of them are for the testing of the networks.

aux_functions_testing.test(dataset_name, descriptors=[], eval_func=None, batch_size=150, population=5, generations=10, iters=100, seed=None, max_filter=4, max_stride=3, lrate=0.01, cxp=0, mtp=1, evol_alg='mu_plus_lambda', sel='best', sel_kwargs={}, max_num_layers=10, max_num_neurons=20, hyperparameters={}, is_time_series=False, series_input_width=30, series_label_width=1)

Responsible of load the desired dataset, prepare it to fit it into the models and it to them. Also it call the evolutionary process in order to evolve those generated models.

Parameters
  • dataset_name – String with the name of one of the available datasets.

  • descriptors – List with the descriptors that will be used in the test.

  • eval_func – Evaluation function that will be used to se the performance of the models.

  • batch_size – Batch size that will be taken form the data during training.

  • population – Number of individuals that will be evaluated in each generation of the evolution algorithm.

  • generations – Number of generations that the evolution algorithm will be executed.

  • iters – Number of iterations that each model will be trained.

  • seed – Seed of the random processes.

  • lrate – Learning rate.

  • cxp – Crossover probability.

  • mtp – Mutation probability.

  • evol_alg – Evolutionary algorithm that will be used (strig or a function).

  • sel – Selection method that will be used (strig or a function).

  • max_num_layers – Maximum number of layer allowed in the initialization of the networks.

  • max_num_neurons – Maximum number of neurons in each layer allowed in the initialization of the networks.

  • hyperparameters – Dictionary with the hyperparameters to be evolved.

  • is_time_series – Boolean that indicates if the processed data is a time series or not.

  • series_input_width – If is a series of data, the width that the input data will have.

  • series_label_width – If is a series of data, the width that the labels will have.

Returns

The last generation, a log book (stats) and the hall of fame (the best individuals found).

aux_functions_testing.select_evaluation(mode)

Given the mode of the dataset (classification or regression), the loss function that has to be used is returned.

Parameters

mode – Mode of the dataset ‘class’ if classification and ‘regr’ if regresion.

Returns

Loss function that sould be used in each case.

aux_functions_testing.load_dataset(dataset_name, is_time_series=False, series_input_width=30, series_label_width=1)

By receiving the dataset’s name is capable of loading and dividing it into train, test and validation.

Parameters
  • dataset_name – String with the name of one of the available datasets.

  • is_time_series – Boolean that indicates if the processed data is a time series or not.

  • series_input_width – If is a series of data, the width that the input data will have.

  • series_label_width – If is a series of data, the width that the labels will have.

Returns

Inidcated dataset separated in the following way X_train, X_test, X_val, y_train, y_test, y_val, mode

aux_functions_testing.load_mushrooms()

Loads the dataset of mushrooms that is inside this library.

Returns

Featurees, labels and the type of problem for the dataset.

aux_functions_testing.load_air_quality()

Loads the dataset of air quality that is inside this library.

Returns

Featurees, labels and the type of problem for the dataset.

aux_functions_testing.load_estambul_values()

Loads the dataset of estambul values that is inside this library.

Returns

Featurees, labels and the type of problem for the dataset.

aux_functions_testing.load_forest_fires()

Loads the dataset of forest fires that is inside this library.

Returns

Featurees, labels and the type of problem for the dataset.

aux_functions_testing.load_forest_types()

Loads the dataset of forest types that is inside this library.

Returns

Featurees, labels and the type of problem for the dataset.

aux_functions_testing.load_parkinsons()

Loads the dataset of parkinsons that is inside this library.

Returns

Featurees, labels and the type of problem for the dataset.

aux_functions_testing.load_CNN(dataset_name)

Loads the desired dataset that is supposed to be in the database of TensorFlow and is for a CNN.

Parameters

dataset_name – String with the name of one of the available datasets.

Returns

Featurees, labels and the type of problem for the dataset.

aux_functions_testing.load_csv(data_directory, data_sep, decimal, label_column, removed_columns)

Loads data in the csv file located in the recceived direction and that follows the received intructions.

Parameters
  • data_directory – Directory where the desired dataset is located.

  • data_sep – Delemiter of data separator in the file.

  • decimal – The way decimal data is expressed in the file.

  • label_column – Name of the column that contains the labels.

  • removed_columns – Columns in the file that are not desired.

Returns

Features and labels of the dataset.

aux_functions_testing.transform_to_time_series(features, labels, input_width, label_width)

Transforms the received features and labels into time series with the desired width in each case.

Parameters
  • features – Features of the orignal data.

  • labels – Labels of the original data.

  • input_width – Desired width for the input data in the time series.

  • label_width – Desired width for the labels in the time series.

Returns

Features and labels from the original data transformed into time series with the desired widths.