reservoirpy.compat.regression_models.RidgeRegression#
- class reservoirpy.compat.regression_models.RidgeRegression(ridge=0.0, workers=-1, dtype=<class 'numpy.float64'>)[source]#
Ridge regression model for reservoir output weights learning.
\[W_{out} = YX^{T} \cdot (XX^{T} + \mathrm{_ridge} \times \mathrm{Id}_{_dim_in})\]where \(W_out\) is the readout matrix learnt through this regression, \(X\) are the internal states, \(Y\) are the targets vectors, and \(_dim_in\) is the internal state dimension (number of units in the reservoir).
By default, ridge coefficient is set to \(0\), which is equivalent to a simple analytic resolution using pseudo-inverse.
Partial fit method allows to concurrently pre-compute \(XX^{T]\) and \(YX^{T}\) when several independent state sequences are provided, for performance, as suggested by [1].
Methods
__init__
([ridge, workers, dtype])clean
()Clean all internal parameters of the model.
fit
([X, Y])Fit states X to targets values Y following the model learning rule.
initialize
([dim_in, dim_out])Initialize the model internal parameters.
partial_fit
(X, Y)Partially fit the states X to the targets values Y.
Attributes
Input dimension of the model (i.e. internal states dimension).
Output dimension of the model.
A boolean indicating wether the internal parameters of the model are initialized or not.
Regularization coefficient of the model.
Wout
- property dim_in#
Input dimension of the model (i.e. internal states dimension).
- property dim_out#
Output dimension of the model.
- fit(X=None, Y=None)[source]#
Fit states X to targets values Y following the model learning rule.
- Parameters:
X (numpy.ndarray or list of numpy.ndarray) – Internal states of the reservoir.
Y (numpy.ndarray or list of numpy.ndarray) – Targets values for each states.
- Returns:
A readout matrix of shape (targets dimension, states dimension + bias (=1)).
- Return type:
- property initialized#
A boolean indicating wether the internal parameters of the model are initialized or not.
- partial_fit(X, Y)[source]#
Partially fit the states X to the targets values Y. This method can be used to pre-compute some steps of the final fitting method.
- Parameters:
X (numpy.ndarray or list of numpy.ndarray) – Internal states of the reservoir.
Y (numpy.ndarray or list of numpy.ndarray) – Targets values for each states.
- property ridge#
Regularization coefficient of the model.