<jupyter_start><jupyter_text>V0.1.6 - Example: F-16 Ground Vibration Test benchmarkExample created by <NAME>**Note**: The following examples do not try to replicate the results of the cited manuscripts. Even the model parameters such as ylag and xlag and size of identification and validation data are not the same of the cited papers. Moreover, sampling rate adjustment and other different data preparation are not handled here.  Reference**The following text was taken from the link http://www.nonlinearbenchmark.org/F16**. **Note**: The reader is reffered to the mentioned website for a complete reference concerning the experiment. For now, this notebook is just a simple example of the performance of SysIdentPy on a real world dataset. A more detailed study of this system will be published in the future.  > The F-16 Ground Vibration Test benchmark features a high order system with clearance and friction nonlinearities at the mounting interface of the payloads.> The experimental data made available to the Workshop participants were acquired on a full-scale F-16 aircraft on the occasion of the Siemens LMS Ground Vibration Testing Master Class, held in September 2014 at the Saffraanberg military basis, Sint-Truiden, Belgium.> During the test campaign, two dummy payloads were mounted at the wing tips to simulate the mass and inertia properties of real devices typically equipping an F-16 in ﬂight. The aircraft structure was instrumented with accelerometers. One shaker was attached underneath the right wing to apply input signals. The dominant source of nonlinearity in the structural dynamics was expected to originate from the mounting interfaces of the two payloads. These interfaces consist of T-shaped connecting elements on the payload side, slid through a rail attached to the wing side. A preliminary investigation showed that the back connection of the right-wing-to-payload interface was the predominant source of nonlinear distortions in the aircraft dynamics, and is therefore the focus of this benchmark study.> A detailed formulation of the identification problem can be found here. All the provided files and information on the F-16 aircraft benchmark system are available for download here. This zip-file contains a detailed system description, the estimation and test data sets, and some pictures of the setup. The data is available in the .csv and .mat file format.> Please refer to the F16 benchmark as:> <NAME> and <NAME>, F-16 aircraft benchmark based on ground vibration test data, 2017 Workshop on Nonlinear System Identification Benchmarks, pp. 19-23, Brussels, Belgium, April 24-26, 2017.<jupyter_code>pip install sysidentpy
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sysidentpy.polynomial_basis import PolynomialNarmax
from sysidentpy.metrics import root_relative_squared_error
import pandas as pd
pd.set_option('display.max_columns', 1000)
f_16 = pd.read_csv(r'../../../examples/datasets/f-16.txt', header=None, names=['x1', 'x2', 'y'])
f_16.shape<jupyter_output><empty_output><jupyter_text>Visualizating the data<jupyter_code>f_16[['x1', 'x2']][0:500].plot(figsize=(12, 8))
f_16['y'][0:2000].plot(figsize=(12, 8))<jupyter_output><empty_output><jupyter_text>Spliting the data<jupyter_code>x1_id, x1_val = f_16['x1'][0:16384].values.reshape(-1, 1), f_16['x1'][16384::].values.reshape(-1, 1)
x2_id, x2_val = f_16['x2'][0:16384].values.reshape(-1, 1), f_16['x2'][16384::].values.reshape(-1, 1)
x_id = np.concatenate([x1_id, x2_id], axis=1)
x_val = np.concatenate([x1_val, x2_val], axis=1)

y_id, y_val = f_16['y'][0:16384].values.reshape(-1, 1), f_16['y'][16384::].values.reshape(-1, 1)<jupyter_output><empty_output><jupyter_text>Setting the lags the inputs<jupyter_code>x1lag = list(range(1, 10))
x2lag = list(range(1, 10))
x2lag<jupyter_output><empty_output><jupyter_text>Model training and evalutation<jupyter_code>model = PolynomialNarmax(# n_terms=8,
                         non_degree=1,
                         order_selection=True,
                         ylag=20, xlag=[x1lag, x2lag],
                         n_inputs = 2,
                         n_info_values=39,
                         info_criteria='bic',
                         extended_least_squares=False,
                         estimator='least_squares')
model.fit(x_id, y_id)
y_hat = model.predict(x_val, y_val)
rrse = root_relative_squared_error(y_val, y_hat)
print(rrse)
results = pd.DataFrame(model.results(err_precision=8, dtype='sci'), columns=['Regressors', 'Parameters', 'ERR'])
results
a, b,c,d = model.residuals(x_val, y_val, y_hat)
model.plot_result(y_val, y_hat, a, b, n=600)<jupyter_output><empty_output><jupyter_text>Information Criteria plot<jupyter_code>xaxis = np.arange(1, model.n_info_values + 1)
plt.plot(xaxis, model.info_values)
plt.xlabel('n_terms')
plt.ylabel('Information Criteria')

# You can use the plot below to choose the "n_terms" and run the model again with the most adequate value of terms.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09012789768185452, 'fraction_numerical': 0.03337330135891287, 'mean_word_length': 4.766129032258065, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '156301', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1458, 'n_words': 544, 'path': 'docs/source/examples-v016/f_16_benchmark.ipynb', 'repo_name': 'samirmartins/sysidentpy', 'size': '5034'}