Spaces:
Sleeping
Sleeping
Download response.py from JoyZhan/BackendPayactiv: direct link, hf CLI and curl.
- Browser
- Download file 2.73 kB
-
https://huggingface.co/spaces/JoyZhan/BackendPayactiv/resolve/main/response.py
- Command line
-
hf download hf://spaces/JoyZhan/BackendPayactiv/response.py
-
curl -L -o response.py https://huggingface.co/spaces/JoyZhan/BackendPayactiv/resolve/main/response.py
2.73 kB
| """Response schemas for the EWA Demand Forecast API.""" | |
| from typing import List, Optional | |
| from pydantic import BaseModel, Field | |
| class ConfidenceInterval(BaseModel): | |
| """Confidence interval for a single forecast step.""" | |
| lower: float = Field(description="Lower bound of the confidence interval") | |
| upper: float = Field(description="Upper bound of the confidence interval") | |
| class ForecastResponse(BaseModel): | |
| """Response body for a single forecast.""" | |
| forecast: List[float] = Field( | |
| description="Point forecast values for each future period" | |
| ) | |
| confidence_intervals: List[ConfidenceInterval] = Field( | |
| description="Confidence intervals corresponding to each forecast step" | |
| ) | |
| confidence_level: float = Field( | |
| description="Confidence level used for the prediction intervals" | |
| ) | |
| alpha: float = Field(description="Level smoothing factor α used in the model") | |
| beta: Optional[float] = Field( | |
| default=None, | |
| description="Trend smoothing factor β used in the model (None = simple smoothing)", | |
| ) | |
| model_type: str = Field( | |
| description=( | |
| "'simple' for single exponential smoothing, " | |
| "'double' for Holt's double exponential smoothing" | |
| ) | |
| ) | |
| rmse: Optional[float] = Field( | |
| default=None, | |
| description="Root Mean Squared Error on the training data (in-sample fit)", | |
| ) | |
| class BatchForecastResponse(BaseModel): | |
| """Response body for a batch of forecasts.""" | |
| results: List[ForecastResponse] = Field( | |
| description="Individual forecast results corresponding to each input item" | |
| ) | |
| total: int = Field(description="Total number of forecasts in this batch") | |
| class ModelInfoResponse(BaseModel): | |
| """Response body for the /model-info endpoint.""" | |
| name: str = Field(description="Model name") | |
| version: str = Field(description="API / model version") | |
| description: str = Field(description="Short description of the model") | |
| supported_models: List[str] = Field( | |
| description="List of supported model variants" | |
| ) | |
| default_alpha: float = Field(description="Default level smoothing factor") | |
| default_beta: float = Field(description="Default trend smoothing factor") | |
| default_horizon: int = Field(description="Default forecast horizon") | |
| default_confidence_level: float = Field(description="Default confidence level") | |
| min_history_length: int = Field( | |
| description="Minimum number of historical data points required" | |
| ) | |
| class HealthResponse(BaseModel): | |
| """Response body for the /health endpoint.""" | |
| status: str = Field(description="Service health status") | |
| version: str = Field(description="API version") | |