gfdl.model.GFDLRegressor#
- class GFDLRegressor(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 = None)[source]#
Random vector functional link network regressor.
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. Whenrtol=None, the array API standard default forpinvis used.
- Attributes:
- n_features_in_int
Number of features seen during fit.
- 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 the fit method.
Methods
fit(X, y)Train the gradient-free neural network on 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 regression target for X.
score(X, y[, sample_weight])Return coefficient of determination on test data.
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
scoremethod.get_generator
See also
GFDLClassifierClassifier variant for the RVFL architecture.
Examples
>>> from gfdl.model import GFDLRegressor >>> from sklearn.datasets import make_regression >>> from sklearn.model_selection import train_test_split >>> X, y = make_regression(n_samples=200, n_features=20, random_state=1) >>> X_train, X_test, y_train, y_test = train_test_split(X, y, ... random_state=1) >>> regr = GFDLRegressor(seed=1) >>> regr.fit(X_train, y_train) GFDLRegressor(seed=1) >>> regr.predict(X_test[:2]) array([ 18.368, -278.014])
- __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 = None)[source]#
Methods
__init__([hidden_layer_sizes, activation, ...])fit(X, y)Train the gradient-free neural network on 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 regression target for X.
score(X, y[, sample_weight])Return coefficient of determination on test data.
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
scoremethod.