Documentation for UOFR
¶
Build NARMAX Models using UOFR algorithm.
UOFR
¶
Bases: OFRBase
Ultra Orthogonal Forward Regression algorithm.
This class uses the UOFR algorithm ([1]) to build NARMAX models. The NARMAX model is described as:
where \(n_y\in \mathbb{N}^*\), \(n_x \in \mathbb{N}\), \(n_e \in \mathbb{N}\), are the maximum lags for the system output and input respectively; \(x_k \in \mathbb{R}^{n_x}\) is the system input and \(y_k \in \mathbb{R}^{n_y}\) is the system output at discrete time \(k \in \mathbb{N}^n\); $e_k \in \mathbb{R}^{n_e}4 stands for uncertainties and possible noise at discrete time \(k\). In this case, \(\mathcal{F}\) is some nonlinear function of the input and output regressors and \(d\) is a time delay typically set to \(d=1\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ylag | int | The maximum lag of the output. | 2 |
xlag | int | The maximum lag of the input. | 2 |
elag | int | The maximum lag of the residues regressors. | 2 |
order_selection | bool | Whether to use information criteria for order selection. | True |
info_criteria | str | The information criteria method to be used. | "aic" |
n_terms | int | The number of the model terms to be selected. Note that n_terms overwrite the information criteria values. | None |
n_info_values | int | The number of iterations of the information criteria method. | 10 |
estimator | str | The parameter estimation method. | "least_squares" |
model_type | str | The user can choose "NARMAX", "NAR" and "NFIR" models | 'NARMAX' |
eps | float | Normalization factor of the normalized filters. | np.finfo(np.float64).eps |
alpha | float | Regularization parameter used in ridge regression. Ridge regression parameter that regularizes the algorithm to prevent over fitting. If the input is a noisy signal, the ridge parameter is likely to be set close to the noise level, at least as a starting point. Entered through the self data structure. | np.finfo(np.float64).eps |
Examples:
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from sysidentpy.model_structure_selection import FROLS
>>> from sysidentpy.basis_function import Polynomial
>>> from sysidentpy.utils.display_results import results
>>> from sysidentpy.metrics import root_relative_squared_error
>>> from sysidentpy.utils.generate_data import get_miso_data, get_siso_data
>>> x_train, x_valid, y_train, y_valid = get_siso_data(n=1000,
... colored_noise=True,
... sigma=0.2,
... train_percentage=90)
>>> basis_function = Polynomial(degree=2)
>>> model = UOFR(basis_function=basis_function,
... order_selection=True,
... n_info_values=10,
... extended_least_squares=False,
... ylag=2,
... xlag=2,
... info_criteria='aic',
... )
>>> model.fit(x_train, y_train)
>>> yhat = model.predict(x_valid, y_valid)
>>> rrse = root_relative_squared_error(y_valid, yhat)
>>> print(rrse)
0.001993603325328823
>>> r = pd.DataFrame(
... results(
... model.final_model, model.theta, model.err,
... model.n_terms, err_precision=8, dtype='sci'
... ),
... columns=['Regressors', 'Parameters', 'ERR'])
>>> print(r)
Regressors Parameters ERR
0 x1(k-2) 0.9000 0.0
1 y(k-1) 0.1999 0.0
2 x1(k-1)y(k-1) 0.1000 0.0
References
- Manuscript: Ultra-Orthogonal Forward Regression Algorithms for the Identification of Non-Linear Dynamic Systems https://eprints.whiterose.ac.uk/107310/1/UOFR%20Algorithms%20R1.pdf
Source code in sysidentpy/model_structure_selection/sobolev_orthogonal_forward_regression.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
augment_uls_terms(y, psi, m=2, test_support=5)
¶
Augment signals for ULS with matching row counts.
Source code in sysidentpy/model_structure_selection/sobolev_orthogonal_forward_regression.py
fit(*, X=None, y)
¶
Fit polynomial NARMAX model.
This is an 'alpha' version of the 'fit' function which allows a friendly usage by the user. Given two arguments, x and y, fit training data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X | ndarray of floats | The input data to be used in the training process. | None |
y | ndarray of floats | The output data to be used in the training process. | required |
Returns:
Name | Type | Description |
---|---|---|
model | ndarray of int | The model code representation. |
piv | array-like of shape = number_of_model_elements | Contains the index to put the regressors in the correct order based on err values. |
theta | array-like of shape = number_of_model_elements | The estimated parameters of the model. |
err | array-like of shape = number_of_model_elements | The respective ERR calculated for each regressor. |
info_values | array-like of shape = n_regressor | Vector with values of akaike's information criterion for models with N terms (where N is the vector position + 1). |
Source code in sysidentpy/model_structure_selection/sobolev_orthogonal_forward_regression.py
gaussian_test_function(t, order)
¶
Generate Gaussian-like test function derivatives.
Source code in sysidentpy/model_structure_selection/sobolev_orthogonal_forward_regression.py
normalize_test_function(phi_j)
¶
Normalize derivatives.
sobolev_error_reduction_ratio(psi, y, process_term_number, m=2, test_support=5)
¶
Define Ultra Orthogonal Least Squares.