Skip to content

Commit 413baa2

Browse files
committed
DOC fix warning message in plot_narx_msa
1 parent b389610 commit 413baa2

File tree

4 files changed

+6
-28
lines changed

4 files changed

+6
-28
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424
- name: Build wheels
25-
uses: pypa/[email protected].0
25+
uses: pypa/[email protected].1
2626
env:
2727
CIBW_BUILD: cp3*-*
2828
CIBW_SKIP: pp* *i686* *musllinux* *-macosx_universal2 *-manylinux_ppc64le *-manylinux_s390x

examples/plot_narx_msa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def plot_prediction(ax, t, y_true, y_pred, title):
130130
y_train_osa_pred = narx_model.predict(u_train, y_init=y_train[:max_delay])
131131
y_test_osa_pred = narx_model.predict(u_test, y_init=y_test[:max_delay])
132132

133-
narx_model.fit(u_train, y_train, coef_init="one_step_ahead")
133+
narx_model.fit(u_train, y_train, coef_init="one_step_ahead", method="Nelder-Mead")
134134
y_train_msa_pred = narx_model.predict(u_train, y_init=y_train[:max_delay])
135135
y_test_msa_pred = narx_model.predict(u_test, y_init=y_test[:max_delay])
136136

@@ -169,7 +169,7 @@ def plot_prediction(ax, t, y_true, y_pred, title):
169169
y_train_osa_pred = narx_model.predict(u_train, y_init=y_train[:max_delay])
170170
y_test_osa_pred = narx_model.predict(u_test, y_init=y_test[:max_delay])
171171

172-
narx_model.fit(u_all, y_all, coef_init="one_step_ahead")
172+
narx_model.fit(u_all, y_all, coef_init="one_step_ahead", method="Nelder-Mead")
173173
y_train_msa_pred = narx_model.predict(u_train, y_init=y_train[:max_delay])
174174
y_test_msa_pred = narx_model.predict(u_test, y_init=y_test[:max_delay])
175175

fastcan/narx.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,12 @@ def fit(self, X, y, sample_weight=None, coef_init=None, **params):
420420
NARX whose coefficients and intercept are initialized by the array.
421421
422422
.. note::
423-
When coef_init is None, missing values (i.e., np.nan) are allowed.
423+
When coef_init is `one_step_ahead`, the model will be trained as a
424+
Multi-Step-Ahead NARX, rather than a One-Step-Ahead NARX.
424425
425426
**params : dict
426427
Keyword arguments passed to
427-
`scipy.optimize.least_squares`.
428+
`scipy.optimize.minimize`.
428429
429430
Returns
430431
-------

tests/test_narx.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -254,26 +254,3 @@ def test_sample_weight():
254254
coef_ = narx.coef_
255255

256256
assert np.any(coef_w != coef_)
257-
258-
import numpy as np
259-
from fastcan.narx import NARX, print_narx
260-
rng = np.random.default_rng(12345)
261-
n_samples = 1000
262-
max_delay = 3
263-
e = rng.normal(0, 0.1, n_samples)
264-
u = rng.uniform(0, 1, n_samples+max_delay) # input
265-
y = np.zeros(n_samples+max_delay) # output
266-
for i in range(max_delay, n_samples+max_delay):
267-
y[i] = 0.5*y[i-1] + 0.7*u[i-2] + 1.5*u[i-1]*u[i-3] + 1
268-
y = y[max_delay:]+e
269-
X = u[max_delay:].reshape(-1, 1)
270-
time_shift_ids = [[0, 1], # u(k-1)
271-
[0, 2], # u(k-2)
272-
[0, 3], # u(k-3)
273-
[1, 1]] # y(k-1)
274-
poly_ids = [[0, 2], # 1*u(k-1)
275-
[0, 4], # 1*y(k-1)
276-
[1, 3]] # u(k-1)*u(k-3)
277-
narx = NARX(time_shift_ids=time_shift_ids,
278-
poly_ids=poly_ids).fit(X, y, coef_init="one_step_ahead")
279-
print_narx(narx)

0 commit comments

Comments
 (0)