swiftemulator.emulators.linear_model module
Linear Model Emulator
- class swiftemulator.emulators.linear_model.LinearModelEmulator(lasso_model_alpha: float = 0.0)[source]
Bases:
BaseEmulatorEmulator that builds an internal linear model (either a basic linear model or a Lasso model), and fits it to the data provided in the model specification, parameters, and values containers.
- Parameters:
lasso_model_alpha (float) – Alpha for the Lasso model. If this is 0.0 (the default) basic linear regression is used.
- lasso_model_alpha: float
- ordering: Optional[List[Hashable]] = None
- parameter_order: Optional[List[str]] = None
- independent_variables: Optional[array] = None
- dependent_variables: Optional[array] = None
- dependent_variable_errors: Optional[array] = None
- model_specification: Optional[ModelSpecification] = None
- model_parameters: Optional[ModelParameters] = None
- model_values: Optional[ModelValues] = None
- emulator: Optional[LinearRegression] = None
- fit_model(model_specification: ModelSpecification, model_parameters: ModelParameters, model_values: ModelValues)[source]
Fits the linear model, given the specification, parameters, and values of the space.
- Parameters:
model_specification (ModelSpecification) – Full instance of the model specification.
model_parameters (ModelParameters) – Full instance of the model parameters.
model_values (ModelValues) – Full instance of the model values describing this individual scaling relation.
- predict_values(independent: array, model_parameters: Dict[str, float]) array[source]
Predict values from the trained emulator contained within this object.
- Parameters:
independent – Independent continuous variables to evaluate the emulator at.
np.array – Independent continuous variables to evaluate the emulator at.
model_parameters (Dict[str, float]) – The point in model parameter space to create predicted values at.
- Returns:
dependent_predictions, np.array – Array of predictions, if the emulator is a function f, these are the predicted values of f(independent) evaluted at the position of the input model_parameters.
dependent_prediction_errors, np.array – Errors on the model predictions. For the linear model these are all zeroes, as the errors are unconstrained.