wilsonrljr / sysidentpy

A Python Package For System Identification Using NARMAX Models
https://sysidentpy.org
BSD 3-Clause "New" or "Revised" License
390 stars 78 forks source link

Example identification_of_an_electromechanical_system.ipynb not working #96

Closed wilsonrljr closed 1 year ago

wilsonrljr commented 1 year ago

Discussed in https://github.com/wilsonrljr/sysidentpy/discussions/92

Originally posted by **ghost** February 13, 2023 Hello, First of all, thanks for the creation of this project, tools for working with NARMAX are not easily available. I am currently evaluating SysIdentPy to be used at work and I am going through some examples and found this example throughs up the following error: ``` ValueError Traceback (most recent call last) Input In [8], in () ----> 1 model.fit(X=x_train, y=y_train) 2 yhat = model.predict(X=x_valid, y=y_valid) 3 rrse = root_relative_squared_error(y_valid, yhat) File ~/sysidentpy/sysidentpy/model_structure_selection/forward_regression_orthogonal_least_squares.py:476, in FROLS.fit(self, X, y) 471 self.regressor_code = self.regressor_space( 472 self.non_degree, self.xlag, self.ylag, self._n_inputs, self.model_type 473 ) 475 if self._order_selection is True: --> 476 self.info_values = self.information_criterion(reg_matrix, y) 478 if self.n_terms is None and self._order_selection is True: 479 model_length = np.where(self.info_values == np.amin(self.info_values)) File ~/sysidentpy/sysidentpy/model_structure_selection/forward_regression_orthogonal_least_squares.py:359, in FROLS.information_criterion(self, X_base, y) 356 n_theta = i + 1 357 regressor_matrix = self.error_reduction_ratio(X_base, y, n_theta)[2] --> 359 tmp_theta = getattr(self, self.estimator)(regressor_matrix, y) 361 tmp_yhat = np.dot(regressor_matrix, tmp_theta) 362 tmp_residual = y[self.max_lag :] - tmp_yhat File ~/sysidentpy/sysidentpy/parameter_estimation/estimators.py:255, in Estimators.recursive_least_squares(self, psi, y) 253 k = np.divide(k_numerator, k_denominator) 254 self.xi[i, 0] = y[i, 0] - np.dot(psi_tmp.T, theta[:, i - 1]) --> 255 theta[:, i] = list(theta[:, i - 1].reshape(-1, 1) + k.dot(self.xi[i, 0])) 257 p1 = p.dot(psi[i, :].reshape(-1, 1)).dot(psi[i, :].reshape(-1, 1).T).dot(p) 258 p2 = ( 259 psi[i, :].reshape(-1, 1).T.dot(p).dot(psi[i, :].reshape(-1, 1)) 260 + self._lam 261 ) ValueError: setting an array element with a sequence. The requested array would exceed the maximum number of dimension of 1. ``` Could you please give me a clue of how to make it work? Have python 3.9, SysIdentPy 0.2.0 running on Mac Monterrey Thanks in advance