profit.sur.linreg
Submodules
Package Contents
Classes
Base class for all Linear Regression models. |
|
Linear regression surrogate using polynomial expansions as basis |
- class profit.sur.linreg.LinearRegression[source]
Bases:
profit.sur.Surrogate
Base class for all Linear Regression models.
- trained
Flag that indicates if the model is already trained and ready to make predictions.
- Type:
bool
- # ToDo
Parameters:
- class profit.sur.linreg.ChaospyLinReg(model=defaults['model'], order=defaults['order'], model_kwargs=defaults['model_kwargs'], sigma_n=defaults['sigma_n'], sigma_p=defaults['sigma_p'])[source]
Bases:
profit.sur.linreg.LinearRegression
Linear regression surrogate using polynomial expansions as basis functions from chaospy https://chaospy.readthedocs.io/en/master/reference/polynomial/index.html
- # ToDo
- property model
- set_model(model, order, model_kwargs=None)[source]
Sets model parameters for surrogate
- Parameters:
model (str) – Name of chaospy model to use
order (int) – Highest order for polynomial basis functions
model_kwargs (dict) – Keyword arguments for the model
- transform(X)[source]
Transforms input data on selected basis functions
- Parameters:
X (ndarray) – Input points
- Returns:
Basis functions evaluated at X
- Return type:
Phi (ndarray)
- train(X, y)[source]
Trains the surrogate on input points X and model outputs y.
Depending on the surrogate, the signature can vary.
- Parameters:
X (ndarray) – Input training points.
y (ndarray) – Observed output data.
fixed_sigma_n (bool) – Whether the noise \(\sigma_n\) is fixed during optimization.
- predict(Xpred, add_data_variance=False)[source]
Predicts model output y for input Xpred based on surrogate.
- Parameters:
Xpred (ndarray/list) – Input points for prediction.
add_data_variance (bool) – Adds the data noise \(\sigma_n^2\) to the prediction variance. This is especially useful for plotting.
- Returns:
- a tuple containing:
ymean (ndarray) Predicted output values at the test input points.
yvar (ndarray): Generally the uncertainty of the fit. For Gaussian Processes this is
the diagonal of the posterior covariance matrix.
- Return type:
tuple
- save_model(path)[source]
Save the model as dict to a .hdf5 file.
- Parameters:
path (str) – Path including the file name, where the model should be saved.