You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/narx.rst
+16-5Lines changed: 16 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,20 +46,31 @@ The discontinuity can be caused by
46
46
lasts for one hour at 1 Hz, and another measurement is carried out at Tuesday and lasts for two hours at 1 Hz
47
47
#. Missing values
48
48
49
-
No matter how the discontinuity is caused, :class:`NARX` treats the discontinuous time series as multiple pieces of continuous time series in the same way.
49
+
As a result, there are two ways to inform :class:`NARX` the training data from different measurement sessions.
50
+
From version 0.5, the difference measurement sessions can be set by `session_sizes` in :meth:`NARX.fit` and :func:`make_narx`.
51
+
Alternatively, different measurement sessions can also be notified by inserting `np.nan` to break the data.
52
+
The following examples show how to notify :class:`NARX` the training data from different measurement sessions.
50
53
51
-
.. note::
52
-
It is easy to notify :class:`NARX` that the time series data are from different measurement sessions by inserting np.nan to break the data. For example,
54
+
.. code-block:: python
53
55
54
56
>>>import numpy as np
55
57
>>> x0 = np.zeros((3, 2)) # First measurement session
56
58
>>> x1 = np.ones((5, 2)) # Second measurement session
57
59
>>> max_delay =2# Assume the maximum delay for NARX model is 2
58
60
>>># Insert (at least max_delay number of) np.nan to break the two measurement sessions
59
61
>>> u = np.r_[x0, [[np.nan, np.nan]]*max_delay, x1]
62
+
>>># Or use session_sizes to break the two measurement sessions
63
+
>>> session_sizes = [3, 5]
60
64
61
-
It is important to break the different measurement sessions by np.nan, because otherwise,
62
-
the model will assume the time interval between the two measurement sessions is the same as the time interval within a session.
65
+
.. note::
66
+
It is important to separate different measurement sessions using either method.
67
+
Otherwise, the model will incorrectly assume that the time interval between two measurement sessions
68
+
is the same as the sampling interval within a session.
69
+
70
+
Actually, the two methods will result in the exact same models when `X` is not None or multiple-step-ahead prediction is not used for training.
71
+
If `X` is None, i.e. Auto-Regression models, and multiple-step-ahead prediction is used for training, only `session_sizes` can
72
+
separate the two measurement sessions.
73
+
Because when using multiple-step-ahead prediction, the optimiser relies on the missing values in inputs `X` rather than output `y`, while Auto-Regression models do not have input `X`.
0 commit comments