{ "cells": [ { "cell_type": "markdown", "id": "educated-affect", "metadata": {}, "source": [ "# V0.1.6 - System Identification Using Adaptative Filters\n", "\n", "Example created by Wilson Rocha Lacerda Junior" ] }, { "cell_type": "markdown", "id": "preliminary-announcement", "metadata": {}, "source": [ "## Generating 1 input 1 output sample data \n", "\n", "The data is generated by simulating the following model:\n", "\n", "$y_k = 0.2y_{k-1} + 0.1y_{k-1}x_{k-1} + 0.9x_{k-1} + e_{k}$\n", "\n", "If *colored_noise* is set to True:\n", "\n", "$e_{k} = 0.8\\nu_{k-1} + \\nu_{k}$\n", "\n", "where $x$ is a uniformly distributed random variable and $\\nu$ is a gaussian distributed variable with $\\mu=0$ and $\\sigma=0.1$\n", "\n", "In the next example we will generate a data with 1000 samples with white noise and selecting 90% of the data to train the model. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pip install sysidentpy" ] }, { "cell_type": "code", "execution_count": 1, "id": "exact-trace", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from sysidentpy.polynomial_basis import PolynomialNarmax\n", "from sysidentpy.metrics import root_relative_squared_error\n", "from sysidentpy.utils.generate_data import get_miso_data, get_siso_data\n", "from sysidentpy.parameter_estimation import Estimators\n", "\n", "x_train, x_valid, y_train, y_valid = get_siso_data(n=1000,\n", " colored_noise=False,\n", " sigma=0.001,\n", " train_percentage=90)" ] }, { "cell_type": "markdown", "id": "convenient-encounter", "metadata": {}, "source": [ "One can create a model object and access the Adaptative Filters available in SysIdentPy individually. If you want to build a regressor matrix and estimate the parameters using only the Adaptative Filter method (not applying FROLS + ERR algorithm), follow the steps bellow." ] }, { "cell_type": "code", "execution_count": 3, "id": "binary-shame", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | 0 | \n", "1 | \n", "2 | \n", "3 | \n", "4 | \n", "5 | \n", "6 | \n", "7 | \n", "8 | \n", "9 | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "1.0 | \n", "0.000000 | \n", "-0.488925 | \n", "-0.242635 | \n", "0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "0.239048 | \n", "0.118630 | \n", "0.058872 | \n", "
1 | \n", "1.0 | \n", "-0.217385 | \n", "0.969823 | \n", "-0.488925 | \n", "0.047256 | \n", "-0.210825 | \n", "0.106285 | \n", "0.940557 | \n", "-0.474171 | \n", "0.239048 | \n", "
2 | \n", "1.0 | \n", "-0.503772 | \n", "-0.628457 | \n", "0.969823 | \n", "0.253787 | \n", "0.316599 | \n", "-0.488570 | \n", "0.394958 | \n", "-0.609492 | \n", "0.940557 | \n", "
3 | \n", "1.0 | \n", "0.804358 | \n", "0.308975 | \n", "-0.628457 | \n", "0.646992 | \n", "0.248526 | \n", "-0.505505 | \n", "0.095465 | \n", "-0.194177 | \n", "0.394958 | \n", "
4 | \n", "1.0 | \n", "-0.379308 | \n", "-0.442970 | \n", "0.308975 | \n", "0.143875 | \n", "0.168022 | \n", "-0.117197 | \n", "0.196222 | \n", "-0.136867 | \n", "0.095465 | \n", "