Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions fastcan/narx.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ def fit(self, X, y, sample_weight=None, coef_init=None, **params):
warnings.warn(
f"output_ids got {self.output_ids_}, which does not "
f"contain all values from 0 to {self.n_outputs_ - 1}."
"The predicted outputs for the missing values will be 0.",
"The prediction for the missing outputs will be a constant"
"(i.e., intercept).",
UserWarning,
)

Expand All @@ -783,6 +784,7 @@ def fit(self, X, y, sample_weight=None, coef_init=None, **params):
for i in range(self.n_outputs_):
output_i_mask = self.output_ids_ == i
if np.sum(output_i_mask) == 0:
intercept[i] = np.mean(y_masked[:, i])
continue
osa_narx.fit(
poly_terms_masked[:, output_i_mask],
Expand Down Expand Up @@ -974,8 +976,8 @@ def _update_dydx(
dydx[k, y_ids, x_ids] = terms

# Update dynamic terms of Jacobian
cfd = np.zeros((n_y, n_y, max_delay), dtype=float)
if max_delay > 0:
if max_delay > 0 and grad_yyd_ids.size > 0:
cfd = np.zeros((n_y, n_y, max_delay), dtype=float)
_update_cfd(
X,
y_hat,
Expand Down
Loading
Loading