-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |