File size: 2,726 Bytes
04bc9df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""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")