BFS

BFS(n_attr, pref_vector1, pref_vector2. n_hidden=[100,200], n_output)

BFS is a subclass of the keras Model module. However, BFS is based on biobjective gradient descent.

The implementation of the BFS module is based on the keras Model module. However, BFS has two objective functions in the network: the classification error (cross entropy) and the sparse group lasso.

Returns a sparse model with features ranked based on the importance of each feature.

Arguments

n_attr: int

Number of attributes in the data

pref_vector1: array

Array containing the coordinates of the first preference vector delimiting the concerned region

pref_vector2: array

Array containing the coordinates of the second preference vector delimiting the concerned region

n_hidden: array, default = [100,200]

Array containing the number of neurons per hidden layer. The size of the array indicates the number of hidden layers. Default: 2 hidden layers of 100 and 200 neurons respectively.

n_output: int, default = 2

Number of classes in the data. By default, the number of classes is 2.

Methods

Compile

compile(init_optimizer='Adam', train_optimizer='Adam', init_learning_rate=0.01,
        train_learning_rate=0.01, metrics = ['accuracy'], **kwargs)

Configures the model for training.

Parameters:

init_optimizer: String, default: ‘Adam’

Name of optimizer to be used for the initialization step. Default optimizer is Adam.

train_optimizer: String, default: ‘Adam’

Name of optimizer to be used for the training step. Default optimizer is Adam.

init_learning_rate: float, default: 0.01

Learning rate to be used for optimization in the initialization step. Default is 0.01.

train_learning_rate: float, default: 0.01

Learning rate to be used for optimization in the training step. Default is 0.01.

metrics: list, default: [‘accuracy’]

List of metrics to be evaluated by the model during training and testing. See keras.metrics for more details on the accepted metrics. Default is the accuracy metric.


fit

fit(X, y, validation_data, callbacks, batch_size = 32, epochs = 500, **kwargs)

Trains the model for a fixed number of epochs (1 epoch = whole dataset iteration).

Parameters

X: array or tensor

Input data. It can be either a NumPy array, or a list of arrays (in case of multiple inputs), or a tensor, or a list of tensors (again, in case of multiple inputs).

y: array or tensor

Target data. Just like X, it can be either array(s) or tensor(s).

validation_split: float, default: 0.2

Fraction of the data that will be used as training.

validation_data: tuple

Data on which to evaluate the loss and any model metrics at the end of each epoch. It can be a tuple of NumPy arrays or tensors. validation_data if designated will override validation_split.

callbacks: list

List of callbacks to apply during training. In addition to the keras.callbacks.History callback, BFS has the checkTrain callback that is also called automatically for switiching between the initialization and training steps of the learning step.

batch_size: int, default: 32

Number of samples per gradient update. By default, the batch size is 32.

epochs: int, default: 500

Number of epochs to train the model. One epoch is an iteration over the entire x and corresponding y data provided. By default, the model will train 500 epochs.

Returns

A History object. Its History.history attribute is a dictionary containing all training loss values, for both losses, and metrics for all epochs as well all validation losses values and validation metrics when found.


predict

predict(x)
x: NumPy array or tensor

Input data. It can be either a NumPy array, or a list of arrays (in case of multiple inputs), or a tensor, or a list of tensors (again, in case of multiple inputs).

Returns

NumPy array(s) of predictions.


evaluate

evaluate(X, y, return_dict= False, **kwargs)

Parameters

X: array or tensor

Input data. It can be either a NumPy array, or a list of arrays (in case of multiple inputs), or a tensor, or a list of tensors (again, in case of multiple inputs).

y: array or tensor

Target data. Just like X, it can be either array(s) or tensor(s).

return_dict: boolean, default: False

If True, evaluate output returned as dictionary instead of list.

Returns

A list of scalars containing both loss values and metrics if applicable.