-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regarding prediction and identified coefficient of input/output models. #52
Comments
Dear SelmaCho, Please consider that you find the output of your model - obtained with the LLS approach - within the output attribute as Id_ARX.Yid; The syntax for fset.validation - usually to be used for model validation on new data, not the same dataset used for model identification - appears wrong, as input/output position needs to be swapped, as: Best |
Thank you for your kind reply, RBDC. I've attached it by github link because I cannot find your email address ^^;;
dt = 1.0
The reason that I need to use a method-function for predicting new output is to optimize manipulated variables.. ValueError Traceback (most recent call last) File ~\Desktop\Python\SysID\sippy\functionset.py:192, in validation(SYS, u, y, Time, k, centering) File ~\anaconda3\envs\SysIDBox\Lib\site-packages\control\timeresp.py:407, in forced_response(sys, T, U, X0, transpose, interpolate, squeeze) File ~\anaconda3\envs\SysIDBox\Lib\site-packages\scipy\signal_ltisys.py:3556, in dlsim(system, u, t, x0) File ~\anaconda3\envs\SysIDBox\Lib\site-packages\scipy\interpolate_polyint.py:80, in _Interpolator1D.call(self, x) File ~\anaconda3\envs\SysIDBox\Lib\site-packages\scipy\interpolate_interpolate.py:755, in interp1d._evaluate(self, x_new) File ~\anaconda3\envs\SysIDBox\Lib\site-packages\scipy\interpolate_interpolate.py:784, in interp1d._check_bounds(self, x_new) ValueError: A value (0.0) in x_new is below the interpolation range's minimum value (1.0). Regards Selma Cho |
I found the answer about question 1). y[k]-0.2474y[k-5]-0.1489y[k-4]-0.1318y[k-3] = 0.1733u[k-1]+0.08442u[k-2]+0.756u[k-3] Really. thanks. |
Hi SelmaCho,about Q1, you are close, but the right solution is as follows: The general difference equation is: here you have about Q2, I run the code, and I did get no errors.. (e.g., Fit accuracy= 0.8843802125888518) Let us know which version of control you have (control.version) and if updating it solves the problem. Best |
Dear RBdC Regards |
Dear Selma, |
Dear RBdC Thank you. Another example does not show an error when using control version 0.9.0 and scipy version 1.11.1. I have one more question. What is the role of "Time" in fset.validation? Do I correctly understand? P.S. Here is a code and data which does not cause an error. -- import packagesimport matplotlib.pyplot as plt, numpy as np, control package settingsplt.rcParams.update({'font.size': 14}) read fired heater identification test data and plotdata = np.loadtxt('IndustrialFiredHeater_SISO.csv', delimiter=',') plotsplt.figure(figsize=(6,2.5)), plt.plot(FG, 'steelblue', linewidth=0.8) plt.figure(figsize=(6,2.5)), plt.plot(TO, 'g', linewidth=0.8) center data before model fittingu_scaler = StandardScaler(with_std=False) y_scaler = StandardScaler(with_std=False) fit ARX model using AICARXmodel = SysID(TO_centered, FG_centered, 'ARX', IC='AIC', na_ord=[1,20], nb_ord=[1,20], delays=[0,5]) read fired heater validation data and plotdata_val = np.loadtxt('IndustrialFiredHeater_SISO_Validation.csv', delimiter=',') plotsplt.figure(figsize=(6,2.5)) plt.figure(figsize=(6,2.5)) center validation dataFG_val_centered, TO_val_centered = u_scaler.fit_transform(FG_val), y_scaler.fit_transform(TO_val) get model's 1-step ahead and 5-step ahead predictions, and simulation responses on validation datasetfrom sippy import functionset as fset TO_val_predicted_1step_centered = np.transpose(fset.validation(ARXmodel, FG_val_centered, TO_val_centered, np.linspace(0,299,300), k=1)) TO_val_predicted_1step = y_scaler.inverse_transform(TO_val_predicted_1step_centered) plt.figure(figsize=(18,7.5)) Best regards. Selma |
Dear Selma, What is the role of "Time" in fset.validation? Do I correctly understand? Best |
Dear SIPPY staff,
I am a beginner of SIPPY to use it for developing MPC framework.
I am studying system identification and SIPPY based on the book published by A. Kumar and Flores-Cerrillo, "Machine learning in python for dynamic process systems".
While I read this book and try some example codes, I wonders how to predict new output of ARX and extract coefficients with difference equation form.
In the manual, it is written that using fset.validation is proper to predict new output; However, its description is ambiguous.
I would appreciate you all if you let me know how to predict the new output or extract coefficients with difference equation format.
Here is my toy problem code:
from sippy import system_identification
from sippy import functionset as fset
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import r2_score # model diagnostics
from statsmodels.graphics.tsaplots import plot_acf # model diagnostics
temp = pd.read_csv('simpleProcess.csv')
data = np.array(temp)
u = data[:,0, None]; y = data[:,1, None]
u_scaler = StandardScaler(with_std=False)
y_scaler = StandardScaler(with_std=False)
u_centered = u_scaler.fit_transform(u)
y_centered = y_scaler.fit_transform(y)
Id_ARX = system_identification(y_centered,u_centered, 'ARX', ARX_orders=[3,3,2]) # y(k)-y(k-1)-y(k-2)-y(k-3)=u(k-1)+u(k-2)+u(k-3)
y_centered_pred = np.transpose(Id_ARX.Yid)
y_centered_pred2 = fset.validation(Id_ARX, y_centered, u_centered, np.linspace(1,999,999), 1)
plt.figure()
plt.plot(y_centered, 'o', label='raw data')
plt.plot(y_centered_pred, '--', label='ARX fit')
plt.legend(); plt.xlabel('k'); plt.ylabel('y')
print('Fit accuracy=', r2_score(y_centered,y_centered_pred))
res = y_centered-y_centered_pred
plot_acf(res,lags=50)
plt.xlabel('lag')
ValueError: A value (0.0) in x_new is below the interpolation range's minimum value (1.0).
The text was updated successfully, but these errors were encountered: