-
Notifications
You must be signed in to change notification settings - Fork 0
Linear Models
Classes of linear models
class LinearModel(Model)Base class for all linear models.
Parameters:
-
params :
Model parameters.
Attributes:
-
params :
Stored model parameters
Initialize the model with parameters.
Parameters:
-
params :
Model-specific parameters.
Make predictions using the model.
Parameters:
-
data : Any
Input data for prediction.
Perform a single training step.
Parameters:
-
input_data : Any
Training data for one step.
Forward pass through the model.
Parameters:
-
input : Any
Model input data.
Save model parameters to file.
Parameters:
-
filepath : str
Path where model parameters should be saved.
Load model parameters from file.
Parameters:
-
filepath : str
Path to saved model parameters.
class KalmanFilter(LinearModel)Kalman Filter decoder.
Parameters:
-
model_params : dict
Dictionary containing 'append_ones_y', 'device', 'return_tensor', and optional 'yhat'.
Attributes:
-
A : ndarray
State transition matrix
-
C : ndarray
Observation matrix
-
W : ndarray
Process noise covariance
-
Q : ndarray
Observation noise covariance
-
yh : ndarray
Current state estimate
Initialize the Kalman Filter.
Parameters:
-
model_params : dict
Model configuration parameters.
Makes the instance callable and returns the result of forward pass.
Parameters:
-
data : ndarray
Observation data for prediction, expected size [n, m]
Returns:
-
ndarray
Prediction results, size [n, k]
Trains the matrices in the model. If append_ones_y is true, a column of ones is added to calculate bias.
Parameters:
-
input_data : tuple
A tuple of (x, y) - x (ndarray) size [n, m]: observation features - y (ndarray) size [n, k]: hidden state features
Runs a forward pass, by calling a predict method (torch or numpy).
Parameters:
-
input : ndarray
size [n, m], where n is the number of samples/data, and m is the number of observation features
Returns:
-
yhat : ndarray
prediction of size [n, k], where n is the number of samples/data, and k is the number of hidden state features
Runs a forward pass, returning a prediction for all input datapoints. If start_y is true, initial state is added.
Parameters:
-
x : ndarray
size [n, m], where n is the number of samples/data, and m is the number of observation features
Returns:
-
yhat : ndarray
prediction of size [n, k], where n is the number of samples/data, and k is the number of hidden state features
Saves the model in its current state at the specified filepath
Parameters:
-
fpath : str
indicates the file path to save the model in
Load model parameters from a specified location
Parameters:
-
fpath : str
indicates the file path to load the model from
Reset initialization state estimate and covariance.
Parameters:
-
yhat : ndarray Initial state estimate.
-
Pt : ndarray, optional Initial error covariance matrix.
class Regression(LinearModel)Base class for regression models using scikit-learn implementations.
Parameters:
-
params : dict
Model parameters.
Attributes:
-
model : sklearn model
Underlying scikit-learn model instance
Initialize the regression model.
Parameters:
-
params : dict
Model parameters.
Make predictions using the model.
Parameters:
-
data : Any
Input data for prediction.
-
is_torch : bool
Whether to return torch tensor.
Returns:
-
Any
Model predictions.
Train the model using scikit-learn fit method.
Parameters:
-
input_data : Any
Training data (X, y).
Forward pass through the model.
Parameters:
-
data : Any
Input data.
-
is_torch : bool
Whether to return torch tensor.
Returns:
-
Any
Model predictions.
Save model to file using pickle.
Parameters:
-
filepath : str
Path to save the model.
Load model from file using pickle.
Parameters:
-
filepath : str
Path to load the model from.
class LinearRegression(Regression)Linear regression model using scikit-learn LinearRegression.
Parameters:
-
params : dict
Parameters passed to sklearn LinearRegression.
Initialize the linear regression model.
Parameters:
-
params : dict
Parameters for sklearn LinearRegression.
class RidgeRegression(Regression)Ridge regression model using scikit-learn Ridge.
Parameters:
-
params : dict
Parameters passed to sklearn Ridge.
Initialize the ridge regression model.
Parameters:
-
params : dict
Parameters for sklearn Ridge.