Skip to content

Commit

Permalink
Create fixed.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow authored Aug 7, 2024
1 parent 478e04c commit f788cfb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions swiftemulator/mean_models/fixed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Fixed mean model. Basic, fixed, 0th order model.
"""

from .base import MeanModel

import numpy as np
import attr

from typing import Optional


@attr.s
class FixedMeanModel(MeanModel):
"""
A basic offset mean model. Uses a fixed (manual) value for the mean
model and does not allow it to be changed.
"""

model: float

def train(self, independent: np.ndarray, dependent: np.ndarray) -> None:
"""
Train the model. See :class:`MeanModel` for more information.
"""

# This is a no-op function because the model is fixed.

return

def predict(self, independent: np.ndarray) -> np.ndarray:
"""
Predict using the model. See :class:`MeanModel` for more information.
"""

dependent = np.ones(independent.shape[0], dtype=independent.dtype) * self.model

return dependent

0 comments on commit f788cfb

Please sign in to comment.