Predictors

Single predictors

Extreme Learning Machine

Also known as single-hidden-layer version of Extreme Learning Machine. Weights for neurons in the hidden layer are chosen randomly.

class pyridge.neural.ELM(classification: bool = True, logging: bool = True)[source]

Neural Ridge classifier, also known as Extreme Learning Machine. It works as a single hidden layer neural network where neuron’s weights are chosen randomly.

fit(train_data, train_target, parameter)[source]

Use some train (data and target) and parameter to fit the classifier and construct the rules.

Parameters
  • train_data (numpy.array) – data with features.

  • train_target (numpy.array) – targets in j codification.

  • parameter (dict) –

get_indicator(test_data)[source]

Once instanced, classifier can predict test target from test data, using some mathematical rules. Valid for other ensembles.

Parameters

test_data (numpy.array) – array like.

Returns

indicator.

instance_weight(train_data, train_target, parameter)[source]

Instance parameters and get weight of neurons.

Parameters
  • train_data

  • train_target

  • parameter

Returns

PCA ELM

PCA LDA ELM

Sobol ELM

Parallel Layer ELM

Kernel ELM

Kernel version of Extreme Learning Machine.

class pyridge.kernel.KernelELM(classification: bool = True, logging: bool = True)[source]

Kernel ELM classifier.

fit(train_data, train_target, parameter)[source]

Use some train (data and target) and parameter to fit the classifier and construct the rules. :param numpy.array train_data: data with features. :param numpy.array train_target: targets in j codification. :param dict parameter:

get_indicator(test_data)[source]

Once instanced, classifier can predict test target from test data, using some mathematical rules. :param numpy.array test_data: matrix of data to predict. :return: matrix.

Artificial Neural Network

class pyridge.neural.nn.NeuralNetwork(classification: bool = True, logging: bool = True)[source]

Simple Neural Network with one hidden layer.

backpropagation(penalty=None)[source]

Adjust the weights after the prediction using all data.

Parameters

penalty – for NC.

fit(train_data, train_target, parameter)[source]

Train the neural network with gradient descent.

Parameters
  • train_data – numpy.array with data (instances and features).

  • train_target – numpy.array with the target to predict.

  • parameter (dict) – keys - max_iter: number of iterations for training. - neurons: number of neurons in the hidden layer. - learning_rate: step to add in each iteration.

get_batches(penalty=None)[source]
get_dE_dW(grad_output, hidden_layer, grad_hidden, data)[source]

Compute de derivate of the Error respect to the weights.

Parameters
  • grad_output

  • hidden_layer

  • grad_hidden

  • data

Returns

get_grads(error)[source]

:param error :return:

get_indicator(test_data)[source]

Predict value.

Parameters

test_data

Returns

get_input_layer()[source]

Weights and bias for input layer.

get_layers()[source]

Feed forward random assignation of the two layers.

initial(train_data, train_target, parameter)[source]

Instance parameters and initial layer.

Parameters
  • train_data

  • train_target

  • parameter

Returns

irprop(penalty=None)[source]

Algorithm iRPROP+ implementation.

Parameters

penalty

sgd(penalty=None)[source]

Adjust the weights after the prediction using a few instances chosen stochastically.

Parameters

penalty – for NC.

update(delta_weight_output, delta_weight_input)[source]

Update for back propagation.

Parameters
  • delta_weight_output

  • delta_weight_input

Returns

Neural Network Ensembles

AdaBoost ELM

AdaBoost meta-algorithm with ELM as base learner.

class pyridge.neural.AdaBoostELM(classification: bool = True)[source]

AdaBoost meta-algorithm applied to Neural ELM.

adaboost_weight(h_matrix, f_pred, s)[source]
Parameters
  • h_matrix

  • f_pred

  • s

Returns

error vector

error_function(f_pred, y)[source]
Parameters
  • f_pred

  • y

Returns

error_vector

fit(train_data, train_target, parameter)[source]

Add array of weights and call super.

Parameters
  • train_data

  • train_target

  • parameter

Returns

fit_step(h_matrix, s: int, y_mu=None)[source]

Each step of the fit process.

Parameters
  • h_matrix

  • s (int) – element of the ensemble.

  • y_mu

Returns

get_indicator(test_data)[source]

Once instanced, classifier can predict test target from test data, using some mathematical rules. Valid for other ensembles.

Parameters

test_data (numpy.array) – array like.

Returns

f(X) vector.

positiveness

alias of builtins.float

predict_classifier(test_data)[source]

Following SAMME algorithm.

Parameters

test_data

Returns

Bagging ELM

Bagging implementation with ELM as base learner.

class pyridge.neural.BaggingELM(classification: bool = True, logging: bool = True)[source]

Bagging implementation for Neural Extreme Learning Machine.

fit(train_data, train_target, parameter)[source]

Use some train (data and target) and parameter to fit the classifier and construct the rules.

Parameters
  • train_data (numpy.array) – data with features.

  • train_target (numpy.array) – targets in j codification.

  • parameter (dict) –

fit_step(train_data, train_target)[source]

Fit with part of the data from the whole set. This proportion can be given in the parameter dict; if not, proportion is 75%.

Parameters
  • train_data

  • train_target

Returns

get_indicator(test_data)[source]

Once instanced, classifier can predict test target from test data, using some mathematical rules. Valid for other ensembles.

Parameters

test_data (numpy.array) – array like.

Returns

predicted labels.

Boosting Ridge ELM

Boosting Ridge with ELM as base learner.

class pyridge.neural.BoostingRidgeELM(classification: bool = True, logging: bool = True)[source]

Boosting Ridge ensemble applied to Neural ELM.

fit(train_data, train_target, parameter)[source]

Use some train (data and target) and parameter to fit the classifier and construct the rules.

Parameters
  • train_data (numpy.array) – data with features.

  • train_target (numpy.array) – targets in j codification.

  • parameter (dict) –

fit_step(h_matrix, s: int, y_mu=None)[source]

Each step of the fit process.

Parameters
  • h_matrix

  • s (int) – element of the ensemble.

  • y_mu

Returns

get_indicator(test_data)[source]

Once instanced, classifier can predict test target from test data, using some mathematical rules. Valid for other ensembles.

Parameters

test_data (numpy.array) – array like.

Returns

f(X) vector.

AdaBoost Negative Correlation ELM

Xin Yao et al. implementation of Negative Correlation and Adaboost.

class pyridge.neural.AdaBoostNCELM(classification: bool = True)[source]

AdaBoost Negative Correlation meta-algorithm applied to Neural ELM.

adaboost_weight(h_matrix, f_pred, s)[source]
Parameters
  • h_matrix

  • f_pred

  • s

Returns

Diverse ELM

Ensemble proposed by Perales et al (2018).

class pyridge.neural.DiverseELM(classification: bool = True, logging: bool = True)[source]

Diverse Extreme Learning Machine.

fit_step(h_matrix, y_mu=None, s: int = 1)[source]

Each step of the fit process.

Parameters
  • h_matrix

  • y_mu

  • s (int) –

Returns

Regularized Ensemble ELM (REELM)

Ensemble proposed by Perales et al (2019).

class pyridge.neural.RegularizedEnsembleELM(classification: bool = True, logging: bool = True)[source]

Regularized Extreme Learning Machine.

fit_step(h_matrix, y_mu=None, s: int = 1)[source]

Each step of the fit process.

Parameters
  • h_matrix

  • y_mu

  • s (int) –

Returns

Negative Correlation Ensembles

Negative Correlation ELM

Ensemble proposed by Perales et al (2020).

class pyridge.negcor.nc_elm.NegativeCorrelationELM(classification: bool = True, logging: bool = True)[source]

Iterative Negative Correlation with Sherman-Morrison, updated.

fit(train_data, train_target, parameter: dict)[source]

Use some train (data and target) and parameter to fit the classifier and construct the rules.

Parameters
  • train_data (numpy.array) – data with features.

  • train_target (numpy.array) – targets in j codification.

  • parameter (dict) –

get_inv_left(f_j, s)[source]
Parameters
  • f_j

  • s (int) –

Returns

Negative Correlation Neural Network

class pyridge.negcor.nc_nn.NegativeCorrelationNN(classification: bool = True, logging: bool = True)[source]

Negative Correlation for Artificial Neural Networks.

It does not inherit from NeuralNetwork because it uses a list for store several of these predictors.

fit(train_data, train_target, parameter)[source]

Train several neural networks and update them with a negative correlation penalty.

Parameters
  • train_data – numpy.array with data (instances and features).

  • train_target – numpy.array with the target to predict.

  • parameter (dict) – keys - max_iter: number of iterations for training. - hidden_neurons: number of neurons in the hidden layer. - learning_rate: step to add in each iteration. - lambda_: coefficient for negative correlation penalty.

get_indicator(test_data)[source]

Predict value.

Parameters

test_data

Returns