pyrcn.linear_model¶
The pyrcn.linear_model module has incremental linear regression.
- class pyrcn.linear_model.IncrementalRegression(*, alpha: float = 1e-05, fit_intercept: bool = True, normalize: bool = False)¶
Bases:
BaseEstimator,RegressorMixinLinear regression.
This linear regression algorithm is able to perform a linear regression with the L2 regularization and iterative fit. [1] .. [1] https://ieeexplore.ieee.org/document/4012031
References
N. Liang, G. Huang, P. Saratchandran and N. Sundararajan, “A Fast and Accurate Online Sequential Learning Algorithm for Feedforward Networks,” in IEEE Transactions on Neural Networks, vol. 17, no. 6, pp. 1411-1423, Nov. 2006, doi: 10.1109/TNN.2006.880583.
- Parameters
alpha (float, default=1e-5) – L2 regularization parameter
fit_intercept (bool, default=True) – Fits a constant offset if True. Use this if input values are not average free.
normalize (bool, default=False) – Performs a preprocessing normalization if True.
- coef_¶
Weight vector(s).
- Type
array, shape (n_features,) or (n_targets, n_features)
- intercept_¶
Independent term in decision function. Set to 0.0 if
fit_intercept = False.- Type
float | array, shape = (n_targets,)
- property coef_: Optional[ndarray]¶
Return the output weights without intercept.
Compatibility to
`sklearn.linear_model.Ridge`.- Returns
coef_ – Weight vector(s).
- Return type
ndarray of shape (n_features,) or (n_targets, n_features)
- fit(X: ndarray, y: ndarray) IncrementalRegression¶
Fit the regressor.
- Parameters
X (ndarray of shape (samples, n_features)) –
y (ndarray of shape (n_samples,) or (n_samples, n_targets)) – The targets to predict.
partial_normalize (bool, default=True) – Partial fits the normalization transformer on this sample if True.
reset (bool, default=False) – Begin a new fit, drop prior fits.
validate (bool, default=True) – Validate input data if True.
postpone_inverse (bool, default=False) – If the output weights have not been fitted yet, regressor might be hinted at postponing inverse calculation.
- Returns
self
- Return type
returns a fitted IncrementalRegression model
- property intercept_: ndarray¶
Return the intercept of output output weights.
Compatibility to
`sklearn.linear_model.Ridge`.- Returns
intercept_ – Independent term in decision function.
- Return type
Union[float, np.ndarray]
- partial_fit(X: ndarray, y: ndarray, partial_normalize: bool = True, reset: bool = False, validate: bool = True, postpone_inverse: bool = False) IncrementalRegression¶
Fit the regressor partially.
- Parameters
X (ndarray of shape (samples, n_features)) –
y (ndarray of shape (n_samples,) or (n_samples, n_targets)) – The targets to predict.
partial_normalize (bool, default=True) – Partial fits the normalization transformer on this sample if True.
reset (bool, default=False) – Begin a new fit, drop prior fits.
validate (bool, default=True) – Validate input data if True.
postpone_inverse (bool, default=False) – If the output weights have not been fitted yet, regressor might be hinted at postponing inverse calculation.
- Returns
self
- Return type
returns a partially fitted IncrementalRegression model
- predict(X: ndarray) ndarray¶
Predict output y according to input X.
- Parameters
X (ndarray of shape (samples, n_features)) –
- Returns
y
- Return type
ndarray of shape (n_samples,) or (n_samples, n_targets)
- set_partial_fit_request(*, partial_normalize: Union[bool, None, str] = '$UNCHANGED$', postpone_inverse: Union[bool, None, str] = '$UNCHANGED$', reset: Union[bool, None, str] = '$UNCHANGED$', validate: Union[bool, None, str] = '$UNCHANGED$') IncrementalRegression¶
Request metadata passed to the
partial_fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topartial_fitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topartial_fit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters
partial_normalize (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
partial_normalizeparameter inpartial_fit.postpone_inverse (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
postpone_inverseparameter inpartial_fit.reset (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
resetparameter inpartial_fit.validate (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
validateparameter inpartial_fit.
- Returns
self – The updated object.
- Return type
object
- set_score_request(*, sample_weight: Union[bool, None, str] = '$UNCHANGED$') IncrementalRegression¶
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns
self – The updated object.
- Return type
object