Documentation for Entropic Regression
¶
Build Polynomial NARMAX Models using the Entropic Regression algorithm.
ER
¶
Bases: BaseMSS
Entropic Regression Algorithm.
Build Polynomial NARMAX model using the Entropic Regression Algorithm ([1]_). This algorithm is based on the Matlab package available on: https://github.com/almomaa/ERFit-Package
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}\) stands for uncertainties and possible noise at discrete time \(k\). In this case, \(\mathcal{F}^\ell\) is some nonlinear function of the input and output regressors with nonlinearity degree \(\ell \in \mathbb{N}\) and \(d\) is a time delay typically set to \(d=1\).
Parameters¶
ylag : int, default=2 The maximum lag of the output. xlag : int, default=2 The maximum lag of the input. k : int, default=2 The kth nearest neighbor to be used in estimation. q : float, default=0.99 Quantile to compute, which must be between 0 and 1 inclusive. p : default=inf, Lp Measure of the distance in Knn estimator. n_perm: int, default=200 Number of permutation to be used in shuffle test estimator : str, default="least_squares" The parameter estimation method. skip_forward = bool, default=False To be used for difficult and highly uncertain problems. Skipping the forward selection results in more accurate solution, but comes with higher computational cost. model_type: str, default="NARMAX" The user can choose "NARMAX", "NAR" and "NFIR" models
Examples¶
import numpy as np import matplotlib.pyplot as plt from sysidentpy.model_structure_selection import ER from sysidentpy.basis_function._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 = ER(basis_function=basis_function, ... ylag=2, xlag=2 ... ) 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® 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¶
- Abd AlRahman R. AlMomani, Jie Sun, and Erik Bollt. How Entropic Regression Beats the Outliers Problem in Nonlinear System Identification. Chaos 30, 013107 (2020).
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
Source code in sysidentpy/model_structure_selection/entropic_regression.py
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 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
|
conditional_mutual_information(y, f1, f2)
¶
Find the conditional mutual information.
Finds the conditioned mutual information between \(y\) and \(f1\) given \(f2\).
This code is based on Matlab Entropic Regression package. https://github.com/almomaa/ERFit-Package
Parameters¶
y : ndarray of floats The source signal. f1 : ndarray of floats The destination signal. f2 : ndarray of floats The condition set.
Returns¶
vp_estimation : float The conditioned mutual information.
References¶
- Abd AlRahman R. AlMomani, Jie Sun, and Erik Bollt. How Entropic Regression Beats the Outliers Problem in Nonlinear System Identification. Chaos 30, 013107 (2020).
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
Source code in sysidentpy/model_structure_selection/entropic_regression.py
entropic_regression_backward(reg_matrix, y, piv)
¶
Entropic Regression Backward Greedy Feature Elimination.
This algorithm is based on the Matlab package available on: https://github.com/almomaa/ERFit-Package
Parameters¶
reg_matrix : ndarray of floats The input data to be used in the prediction process. y : ndarray of floats The output data to be used in the prediction process. piv : ndarray of ints The set of indices to investigate
Returns¶
piv : ndarray of ints The set of remaining indices after the Backward Greedy Feature Elimination.
Source code in sysidentpy/model_structure_selection/entropic_regression.py
entropic_regression_forward(reg_matrix, y)
¶
Entropic Regression Forward Greedy Feature Selection.
This algorithm is based on the Matlab package available on: https://github.com/almomaa/ERFit-Package
Parameters¶
reg_matrix : ndarray of floats The input data to be used in the prediction process. y : ndarray of floats The output data to be used in the prediction process.
Returns¶
selected_terms : ndarray of ints The set of selected regressors after the Forward Greedy Feature Selection. success : boolean Indicate if the forward selection succeed. If high degree of uncertainty is detected, and many parameters are selected, the success flag will be set to false. Then, the backward elimination will be applied for all indices.
Source code in sysidentpy/model_structure_selection/entropic_regression.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
fit(*, X=None, y=None)
¶
Fit polynomial NARMAX model using AOLS algorithm.
The 'fit' function allows a friendly usage by the user. Given two arguments, X and y, fit training data.
The Entropic Regression algorithm is based on the Matlab package available on: https://github.com/almomaa/ERFit-Package
Parameters¶
X : ndarray of floats The input data to be used in the training process. y : ndarray of floats The output data to be used in the training process.
Returns¶
model : ndarray of int The model code representation. theta : array-like of shape = number_of_model_elements The estimated parameters of the model.
References¶
- Abd AlRahman R. AlMomani, Jie Sun, and Erik Bollt. How Entropic Regression Beats the Outliers Problem in Nonlinear System Identification. Chaos 30, 013107 (2020).
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
Source code in sysidentpy/model_structure_selection/entropic_regression.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
|
mutual_information_knn(y, y_perm)
¶
Find the mutual information.
Finds the mutual information between \(x\) and \(y\) given \(z\).
This code is based on Matlab Entropic Regression package.
Parameters¶
y : ndarray of floats The source signal. y_perm : ndarray of floats The destination signal.
Returns¶
ksg_estimation : float The conditioned mutual information.
References¶
- Abd AlRahman R. AlMomani, Jie Sun, and Erik Bollt. How Entropic Regression Beats the Outliers Problem in Nonlinear System Identification. Chaos 30, 013107 (2020).
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
Source code in sysidentpy/model_structure_selection/entropic_regression.py
predict(*, X=None, y=None, steps_ahead=None, forecast_horizon=None)
¶
Return the predicted values given an input.
The predict function allows a friendly usage by the user. Given a previously trained model, predict values given a new set of data.
Parameters¶
X : ndarray of floats The input data to be used in the prediction process. y : ndarray of floats The output data to be used in the prediction process. steps_ahead : int (default = None) The user can use free run simulation, one-step ahead prediction and n-step ahead prediction. forecast_horizon : int, default=None The number of predictions over the time.
Returns¶
yhat : ndarray of floats The predicted values of the model.
Source code in sysidentpy/model_structure_selection/entropic_regression.py
tolerance_estimator(y)
¶
Tolerance Estimation for mutual independence test.
Finds the conditioned mutual information between \(y\) and \(f1\) given \(f2\).
This code is based on Matlab Entropic Regression package. https://github.com/almomaa/ERFit-Package
Parameters¶
y : ndarray of floats The source signal.
Returns¶
tol : float The tolerance value given q.
References¶
- Abd AlRahman R. AlMomani, Jie Sun, and Erik Bollt. How Entropic Regression Beats the Outliers Problem in Nonlinear System Identification. Chaos 30, 013107 (2020).
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004
- Alexander Kraskov, Harald St¨ogbauer, and Peter Grassberger. Estimating mutual information. Physical Review E, 69:066-138,2004