Documentation for Neural NARX
¶
Utilities fo data validation.
check_X_y(X, y)
¶
Validate input and output data using some crucial tests.
Parameters¶
X : ndarray of floats The input data. y : ndarray of floats The output data.
Source code in sysidentpy/utils/_check_arrays.py
check_dimension(X, y)
¶
Check if X and y have only real values.
If there is any string or object samples a ValueError is raised.
Parameters¶
X : ndarray of floats The input data. y : ndarray of floats The output data.
Source code in sysidentpy/utils/_check_arrays.py
check_infinity(X, y)
¶
Check that X and y have no NaN or Inf samples.
If there is any NaN or Inf samples a ValueError is raised.
Parameters¶
X : ndarray of floats The input data. y : ndarray of floats The output data.
Source code in sysidentpy/utils/_check_arrays.py
check_length(X, y)
¶
Check that X and y have the same number of samples.
If the length of X and y are different a ValueError is raised.
Parameters¶
X : ndarray of floats The input data. y : ndarray of floats The output data.
Source code in sysidentpy/utils/_check_arrays.py
check_nan(X, y)
¶
Check that X and y have no NaN or Inf samples.
If there is any NaN or Inf samples a ValueError is raised.
Parameters¶
X : ndarray of floats The input data. y : ndarray of floats The output data.
Source code in sysidentpy/utils/_check_arrays.py
check_random_state(seed)
¶
Turn seed
into a np.random.RandomState
instance.
Parameters¶
seed : {None, int, numpy.random.Generator
, numpy.random.RandomState
}, optional If seed
is None (or np.random
), the numpy.random.RandomState
singleton is used. If seed
is an int, a new RandomState
instance is used, seeded with seed
. If seed
is already a Generator
or RandomState
instance then that instance is used.
Returns¶
seed : {numpy.random.Generator
, numpy.random.RandomState
} Random number generator.
Source code in sysidentpy/utils/_check_arrays.py
Display results formatted for the user.
results(final_model=None, theta=None, err=None, n_terms=None, theta_precision=4, err_precision=8, dtype='dec')
¶
Write the model regressors, parameters and ERR values.
This function returns the model regressors, its respective parameter and ERR value on a string matrix.
Parameters¶
theta_precision : int (default: 4) Precision of shown parameters values. err_precision : int (default: 8) Precision of shown ERR values. dtype : string (default: 'dec') Type of representation: sci - Scientific notation; dec - Decimal notation.
Returns¶
output_matrix : string Where: First column represents each regressor element; Second column represents associated parameter; Third column represents the error reduction ratio associated to each regressor.
Source code in sysidentpy/utils/display_results.py
Utilities for data generation.
get_miso_data(n=5000, colored_noise=False, sigma=0.05, train_percentage=90)
¶
Perform the Error Reduction Ration algorithm.
Parameters¶
n : int The number of samples. colored_noise : bool Select white noise or colored noise (autoregressive noise). sigma : float The standard deviation of the random distribution to generate the noise. train_percentage : int The percentage of the data to be used as train data.
Returns¶
x_train, x_valid : array-like The input data to be used in identification and validation, respectively. y_train, y_valid : array-like The output data to be used in identification and validation, respectively.
Source code in sysidentpy/utils/generate_data.py
get_siso_data(n=5000, colored_noise=False, sigma=0.05, train_percentage=90)
¶
Perform the Error Reduction Ration algorithm.
Parameters¶
n : int The number of samples. colored_noise : bool Select white noise or colored noise (autoregressive noise). sigma : float The standard deviation of the random distribution to generate the noise. train_percentage : int The percentage of the data to be used as train data.
Returns¶
x_train, x_valid : array-like The input data to be used in identification and validation, respectively. y_train, y_valid : array-like The output data to be used in identification and validation, respectively.
Source code in sysidentpy/utils/generate_data.py
Utils methods for NARMAX modeling.
regressor_code(*, X=None, xlag=2, ylag=2, model_type='NARMAX', model_representation=None, basis_function=None)
¶
Generate a regressor code based on the provided parameters.
Parameters¶
X : np.ndarray, optional The input feature matrix. xlag : int, optional The number of lags for the input features. ylag : int, optional The number of lags for the target variable. model_type : str, optional The type of model to be used. Default is "NARMAX". model_representation : str, optional The model representation to be used. basis_function : object, optional The basis function object used to transform the regressor space.
Returns¶
encoding : np.ndarray The generated regressor encoding.
Source code in sysidentpy/utils/narmax_tools.py
set_weights(*, static_function=True, static_gain=True, start=-0.01, stop=-5, num=50, base=2.71)
¶
Set log-spaced weights assigned to each objective in the MO optimization.
Parameters¶
static_function : bool, optional Indicator for the presence of static function data. Default is True. static_gain : bool, optional Indicator for the presence of static gain data. Default is True. start : float, optional The starting exponent for the log-spaced weights. Default is -0.01. stop : float, optional The stopping exponent for the log-spaced weights. Default is -5. num : int, optional The number of weights to generate. Default is 50. base : float, optional The base of the logarithm used to generate weights. Default is 2.71.
Returns¶
weights : ndarray of floats An array containing the weights for each objective.
Notes¶
This method calculates the weights to be assigned to different objectives in multi-objective optimization. The choice of weights depends on the presence of static function and static gain data. If both are present, a set of weights for dynamic, gain, and static objectives is computed. If either static function or static gain is absent, a simplified set of weights is generated.
Source code in sysidentpy/utils/narmax_tools.py
train_test_split(X, y, test_size=0.25)
¶
Split the time series dataset into training and testing sets.
Parameters¶
X : np.ndarray, optional The feature matrix. Can be None if there are no features. y : np.ndarray The target vector. test_size : float, optional The proportion of the dataset to include in the test split. Default is 0.25.
Returns¶
X_train : np.ndarray or None The training set feature matrix, or None if X is None. X_test : np.ndarray or None The testing set feature matrix, or None if X is None. y_train : np.ndarray The training set target vector. y_test : np.ndarray The testing set target vector.
Source code in sysidentpy/utils/narmax_tools.py
Plotting methods.
plot_residues_correlation(data=None, *, figsize=(10, 6), n=100, style='default', facecolor='white', title='Residual Analysis', ylabel='Correlation')
¶
Plot the residual validation.
Source code in sysidentpy/utils/plotting.py
plot_results(y, *, yhat, n=100, title='Free run simulation', xlabel='Samples', ylabel='y, $\\hat{y}$', data_color='#1f77b4', model_color='#ff7f0e', marker='o', model_marker='*', linewidth=1.5, figsize=(10, 6), style='default', facecolor='white')
¶
Plot the results of a simulation.
Parameters¶
y : np.ndarray True data values. yhat : np.ndarray Model predictions. n : int Number of samples to plot. title : str Plot title. xlabel : str Label for the x-axis. ylabel : str Label for the y-axis. data_color : str Color for the data line. model_color : str Color for the model line. marker : str Marker style for the data line. model_marker : str Marker style for the model line. linewidth : float Line width for both lines. figsize : Tuple[int, int] Figure size (width, height). style : str Matplotlib style. facecolor : str Figure facecolor.
Source code in sysidentpy/utils/plotting.py
load_model(*, file_name='model', path=None)
¶
Load the model from file "file_name.syspy" located at path "path".
Parameters¶
file_name: file name (str), along with .syspy extension of the file containing model to be loaded path: location where "file_name.syspy" is (optional).
Returns¶
model_loaded: model loaded, as a variable, containing model and its attributes
Source code in sysidentpy/utils/save_load.py
save_model(*, model=None, file_name='model', path=None)
¶
Save the model "model" in folder "folder" using an extension .syspy.
Parameters¶
model: the model variable to be saved file_name: file name, along with .syspy extension path: location where the model will be saved (optional)
Returns¶
file file_name.syspy located at "path", containing the estimated model.