BCM

BCM class : it inherits from Base class and implements the unsupervised neural network based on the BCM learning rule. Notice that the model has some specific parameters to set the lateral interaction strength between neurons or to force the synaptic weights vectors to be orthogonal.

class biolearn.model.bcm.BCM(inputs=None, outputs=100, num_epochs=100, batch_size=100, weights_init=Normal(mu=0.0, std=1.0), activation=Logistic(), optimizer=SGD(lr_max=inf, lr_min=0.0, decay=0.0, lr=0.02), orthogonalization=False, interaction_strength=0.0, precision=1e-30, epochs_for_convergency=None, convergency_atol=0.01, random_state=None, verbose=True)[source]

Bases: Base

Parameters
  • inputs (int (default=None)) – Number of input units

  • outputs (int (default=100)) – Number of hidden units

  • num_epochs (int (default=100)) – Maximum number of epochs for model convergency

  • batch_size (int (default=10)) – Size of the minibatch

  • weights_init (BaseWeights (default=Normal)) – Weights initialization strategy object

  • activation (Activations (default=Logistic)) – Activation function object

  • optimizer (Optimizer (default=SGD)) – Optimizer object

  • orthogonalization (bool (default=False)) – Turn on/off the synaptic weights orthogonalization algorithm

  • interaction_strength (float (default=0.)) – Set the lateral interaction strenght between weights

  • precision (float (default=1e-30)) – Parameter that controls numerical precision of the weight updates

  • epochs_for_convergency (int (default=None)) – Number of stable epochs requested for the convergency. If None the training proceeds up to the maximum number of epochs (num_epochs)

  • convergency_atol (float (default=0.01)) – Absolute tolerance requested for the convergency

  • random_state (int (default=None)) – Random seed for weights generation

  • verbose (bool (default=True)) – Turn on/off the verbosity

fit(X, y=None)

Fit the biolearn model weights.

Parameters
  • X (array-like of shape (n_samples, n_features)) – The training input samples

  • y (array-like, default=None) – The array of labels

Returns

self – Return self

Return type

object

fit_transform(X, y=None)

Fit the model model meta-transformer and apply the data encoding transformation.

Parameters
  • X (array-like of shape (n_samples, n_features)) – The training input samples

  • y (array-like, shape (n_samples,)) – The target values

Returns

Xnew – The data encoded according to the model weights.

Return type

array-like of shape (n_samples, encoded_features)

get_params(deep=True)

Get parameters for this estimator.

Parameters

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params – Parameter names mapped to their values.

Return type

dict

load_weights(filename)

Load the weight matrix from a binary file.

Parameters

filename (str) – Filename or path

Returns

self – Return self

Return type

object

predict(X, y=None)

Reduce X applying the biolearn encoding.

Parameters
  • X (array of shape (n_samples, n_features)) – The input samples

  • y (array-like, default=None) – The array of labels

Returns

Xnew – The encoded features

Return type

array of shape (n_values, n_samples)

save_weights(filename)

Save the current weights to a binary file.

Parameters

filename (str) – Filename or path

Return type

True if everything is ok

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**params (dict) – Estimator parameters.

Returns

self – Estimator instance.

Return type

estimator instance

transform(X)

Apply the data reduction according to the features in the best signature found.

Parameters

X (array-like of shape (n_samples, n_features)) – The input samples

Returns

Xnew – The data encoded according to the model weights.

Return type

array-like of shape (n_samples, encoded_features)