gfdl.model.GFDLClassifier#

class GFDLClassifier(hidden_layer_sizes: ArrayLike = (100,), activation: str = 'identity', weight_scheme: str = 'uniform', direct_links: bool = True, seed: int = None, reg_alpha: float = None, rtol: float = None)[source]#

Random vector functional link network classifier.

This model fits a feedforward neural network with fixed random hidden-layer parameters and solves for the output weights using linear least squares or ridge regression. When direct links are disabled, the model architecture corresponds to an Extreme Learning Machine (ELM) architecture.

Parameters:
hidden_layer_sizesarray-like of shape (n_layers,), default=(100,)

The ith element represents the number of neurons in the ith hidden layer.

activationstr, default=’identity’

Activation function for the hidden layers.

  • ‘identity’, no-op activation, useful to implement linear bottleneck, returns f(x) = x

  • ‘tanh’: tanh.

  • ‘relu’: relu.

  • ‘sigmoid’: sigmoid.

  • ‘softmax’: softmax.

  • ‘softmin’: softmin.

  • ‘log_sigmoid’: log_sigmoid.

  • ‘log_softmax’: log_softmax.

weight_schemestr, default=’uniform’

Distribution used to initialize the random hidden-layer weights.

The initialization functions generate weight matrices of shape (n_hidden_units, n_features), where values are drawn according to the selected scheme.

  • ‘zeros’: set weights to zeros (zeros).

  • ‘range’: set weights to normalized np.arange (range).

  • ‘uniform’: uniform distribution (uniform).

  • ‘he_uniform’: He uniform distribution (he_uniform).

  • ‘lecun_uniform’: Lecun uniform distribution (lecun_uniform).

  • ‘glorot_uniform’: Glorot uniform distribution (glorot_uniform).

  • ‘normal’: Normal distribution (normal).

  • ‘he_normal’: He normal distribution (he_normal).

  • ‘lecun_normal’: Lecun normal distribution (lecun_normal).

  • ‘glorot_normal’: Glorot normal distribution (glorot_normal).

direct_linksbool, default=True

Whether to connect input layer to output nodes. When set to False, only the hidden-layer activations are used, corresponding to the Extreme Learning Machine (ELM) architecture.

seedint, RandomState instance, default=None

Determines random number generation for weights and bias initialization. Pass an int for reproducible results across multiple function calls. See Glossary.

reg_alphafloat, default=None

Amount of ridge shrinkage to apply in order to improve conditioning during Ridge regression. When set to zero or None, model uses direct solve using Moore-Penrose Pseudo-Inverse.

rtolfloat, default=None

Cutoff for small singular values for the Moore-Penrose pseudo-inverse. Only applies when reg_alpha=None. When rtol=None, the array API standard default for pinv is used.

Attributes:
n_features_in_int

Number of features seen during fit.

classes_ndarray or list of ndarray of shape (n_classes,)

Class labels for each output.

W_list of ndarray of shape (n_layers,)

Weight matrices of the hidden layers. The ith element in the list represents the weight matrix corresponding to layer i.

b_list of ndarray of shape (n_layers,)

Bias vectors of the hidden layers. The ith element in the list represents the bias term corresponding to layer i.

coeff_ndarray of shape (n_features_out, n_outputs)

Output weight matrix learned by fit method.

Methods

fit(X, y)

Build a gradient-free neural network from the training set (X, y).

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict class for X.

predict_proba(X)

Predict class probabilities for X.

score(X, y[, sample_weight])

Return accuracy on provided data and labels.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Configure whether metadata should be requested to be passed to the score method.

get_generator

See also

GFDLRegressor

Regressor variant for the RVFL architecture.

Examples

>>> from gfdl.model import GFDLClassifier
>>> from sklearn.datasets import make_classification
>>> from sklearn.model_selection import train_test_split
>>> X, y = make_classification(n_samples=100, random_state=1)
>>> X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y,
...                                                     random_state=1)
>>> clf = GFDLClassifier(seed=1).fit(X_train, y_train)
>>> clf.predict_proba(X_test[:1])
array([[0.46123716, 0.53876284]])
>>> clf.predict(X_test[:5, :])
array([1, 0, 1, 0, 1])
__init__(hidden_layer_sizes: ArrayLike = (100,), activation: str = 'identity', weight_scheme: str = 'uniform', direct_links: bool = True, seed: int = None, reg_alpha: float = None, rtol: float = None)[source]#

Methods

__init__([hidden_layer_sizes, activation, ...])

fit(X, y)

Build a gradient-free neural network from the training set (X, y).

get_generator(seed)

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict class for X.

predict_proba(X)

Predict class probabilities for X.

score(X, y[, sample_weight])

Return accuracy on provided data and labels.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Configure whether metadata should be requested to be passed to the score method.