@@ -274,9 +274,9 @@ def _mask_missing_value(*arr):
274
274
return tuple ([x [mask_nomissing ] for x in arr ])
275
275
276
276
277
- class Narx (RegressorMixin , BaseEstimator ):
277
+ class NARX (RegressorMixin , BaseEstimator ):
278
278
"""The Nonlinear Autoregressive eXogenous (NARX) model class.
279
- For example, a (polynomial) Narx model is like
279
+ For example, a (polynomial) NARX model is like
280
280
y(t) = y(t-1)*u(t-1) + u(t-1)^2 + u(t-2) + 1.5
281
281
where y(t) is the system output at time t,
282
282
u(t) is the system input at time t,
@@ -333,7 +333,7 @@ class Narx(RegressorMixin, BaseEstimator):
333
333
Examples
334
334
--------
335
335
>>> import numpy as np
336
- >>> from fastcan.narx import Narx , print_narx
336
+ >>> from fastcan.narx import NARX , print_narx
337
337
>>> rng = np.random.default_rng(12345)
338
338
>>> n_samples = 1000
339
339
>>> max_delay = 3
@@ -351,7 +351,7 @@ class Narx(RegressorMixin, BaseEstimator):
351
351
>>> poly_ids = [[0, 2], # 1*u(k-1)
352
352
... [0, 4], # 1*y(k-1)
353
353
... [1, 3]] # u(k-1)*u(k-3)
354
- >>> narx = Narx (time_shift_ids=time_shift_ids,
354
+ >>> narx = NARX (time_shift_ids=time_shift_ids,
355
355
... poly_ids=poly_ids).fit(X, y, coef_init="one_step_ahead")
356
356
>>> print_narx(narx)
357
357
| Term | Coef |
@@ -397,16 +397,16 @@ def fit(self, X, y, sample_weight=None, coef_init=None, **params):
397
397
398
398
sample_weight : array-like of shape (n_samples,), default=None
399
399
Individual weights for each sample, which are used for a One-Step-Ahead
400
- Narx .
400
+ NARX .
401
401
402
402
coef_init : array-like of shape (n_terms,), default=None
403
403
The initial values of coefficients and intercept for optimization.
404
- When `coef_init` is None, the model will be a One-Step-Ahead Narx .
404
+ When `coef_init` is None, the model will be a One-Step-Ahead NARX .
405
405
When `coef_init` is `one_step_ahead`, the model will be a Multi-Step-Ahead
406
- Narx whose coefficients and intercept are initialized by the a
407
- One-Step-Ahead Narx .
406
+ NARX whose coefficients and intercept are initialized by the a
407
+ One-Step-Ahead NARX .
408
408
When `coef_init` is an array, the model will be a Multi-Step-Ahead
409
- Narx whose coefficients and intercept are initialized by the array.
409
+ NARX whose coefficients and intercept are initialized by the array.
410
410
411
411
.. note::
412
412
When coef_init is None, missing values (i.e., np.nan) are allowed.
@@ -477,7 +477,7 @@ def fit(self, X, y, sample_weight=None, coef_init=None, **params):
477
477
n_terms = self .poly_ids_ .shape [0 ] + 1
478
478
479
479
if isinstance (coef_init , (type (None ), str )):
480
- # fit a one-step-ahead Narx model
480
+ # fit a one-step-ahead NARX model
481
481
xy_hstack = np .c_ [X , y ]
482
482
osa_narx = LinearRegression ()
483
483
time_shift_vars = make_time_shift_features (xy_hstack , self .time_shift_ids_ )
@@ -508,7 +508,7 @@ def fit(self, X, y, sample_weight=None, coef_init=None, **params):
508
508
)
509
509
510
510
lsq = least_squares (
511
- Narx ._residual ,
511
+ NARX ._residual ,
512
512
x0 = coef_init ,
513
513
args = (
514
514
self ._expression ,
@@ -578,7 +578,7 @@ def _residual(
578
578
coef = coef_intercept [:- 1 ]
579
579
intercept = coef_intercept [- 1 ]
580
580
581
- y_hat = Narx ._predict (expression , X , y [:max_delay ], coef , intercept , max_delay )
581
+ y_hat = NARX ._predict (expression , X , y [:max_delay ], coef , intercept , max_delay )
582
582
583
583
y_masked , y_hat_masked = _mask_missing_value (y , y_hat )
584
584
@@ -622,7 +622,7 @@ def predict(self, X, y_init=None):
622
622
f"but got { y_init .shape } ."
623
623
)
624
624
625
- return Narx ._predict (
625
+ return NARX ._predict (
626
626
self ._expression ,
627
627
X ,
628
628
y_init ,
@@ -639,7 +639,7 @@ def __sklearn_tags__(self):
639
639
640
640
@validate_params (
641
641
{
642
- "narx" : [Narx ],
642
+ "narx" : [NARX ],
643
643
"term_space" : [Interval (Integral , 1 , None , closed = "left" )],
644
644
"coef_space" : [Interval (Integral , 1 , None , closed = "left" )],
645
645
"float_precision" : [Interval (Integral , 0 , None , closed = "left" )],
@@ -652,12 +652,12 @@ def print_narx(
652
652
coef_space = 10 ,
653
653
float_precision = 3 ,
654
654
):
655
- """Print a Narx model as a Table which contains Term and Coef.
655
+ """Print a NARX model as a Table which contains Term and Coef.
656
656
657
657
Parameters
658
658
----------
659
- narx : Narx model
660
- The Narx model to be printed.
659
+ narx : NARX model
660
+ The NARX model to be printed.
661
661
662
662
term_space: int, default=20
663
663
The space for the column of Term.
@@ -671,14 +671,14 @@ def print_narx(
671
671
Returns
672
672
-------
673
673
table : str
674
- The table of terms and coefficients of the Narx model.
674
+ The table of terms and coefficients of the NARX model.
675
675
676
676
Examples
677
677
--------
678
678
>>> from sklearn.datasets import load_diabetes
679
- >>> from fastcan.narx import print_narx, Narx
679
+ >>> from fastcan.narx import print_narx, NARX
680
680
>>> X, y = load_diabetes(return_X_y=True)
681
- >>> print_narx(Narx ().fit(X, y), term_space=10, coef_space=5, float_precision=0)
681
+ >>> print_narx(NARX ().fit(X, y), term_space=10, coef_space=5, float_precision=0)
682
682
| Term |Coef |
683
683
==================
684
684
|Intercept | 152 |
@@ -765,7 +765,7 @@ def make_narx(
765
765
refine_max_iter = None ,
766
766
** params ,
767
767
):
768
- """Find `time_shift_ids` and `poly_ids` for a Narx model.
768
+ """Find `time_shift_ids` and `poly_ids` for a NARX model.
769
769
770
770
Parameters
771
771
----------
@@ -810,8 +810,8 @@ def make_narx(
810
810
811
811
Returns
812
812
-------
813
- narx : Narx
814
- Narx instance.
813
+ narx : NARX
814
+ NARX instance.
815
815
816
816
Examples
817
817
--------
@@ -912,4 +912,4 @@ def make_narx(
912
912
- 1
913
913
)
914
914
915
- return Narx (time_shift_ids = time_shift_ids , poly_ids = poly_ids )
915
+ return NARX (time_shift_ids = time_shift_ids , poly_ids = poly_ids )
0 commit comments