Spaces:
Running
Running
Download models/base_model.py from 3VVM/MYTHOSLIVE: direct link, hf CLI and curl.
- Browser
- Download file 750 Bytes
-
https://huggingface.co/spaces/3VVM/MYTHOSLIVE/resolve/main/models/base_model.py
- Command line
-
hf download hf://spaces/3VVM/MYTHOSLIVE/models/base_model.py
-
curl -L -o base_model.py https://huggingface.co/spaces/3VVM/MYTHOSLIVE/resolve/main/models/base_model.py
750 Bytes
| import numpy as np | |
| import pandas as pd | |
| from abc import ABC, abstractmethod | |
| def validate_history_and_horizon(history, horizon: int, model_name: str) -> None: | |
| if horizon < 1: | |
| raise ValueError(f'{model_name}: horizon must be >= 1, got {horizon}.') | |
| values = np.asarray(pd.Series(history).astype(float), dtype=float) | |
| if not np.all(np.isfinite(values)): | |
| raise ValueError(f'{model_name}: price history contains NaN/inf. This usually means a data glitch left a missing or malformed candle -- re-fetch the history and try again.') | |
| class BaseForecastModel(ABC): | |
| name = 'base' | |
| def predict(self, history: pd.Series, horizon: int=1, features: pd.DataFrame=None) -> list: | |
| raise NotImplementedError |