Spaces:
Sleeping
Sleeping
File size: 1,874 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 | """Request schemas for the EWA Demand Forecast API."""
from typing import Annotated, List, Optional
from pydantic import BaseModel, Field
class ForecastRequest(BaseModel):
"""Request body for a single forecast."""
history: Annotated[
List[float],
Field(
min_length=2,
description="Historical demand time series (ordered from oldest to most recent)",
examples=[[120.0, 135.0, 148.0, 160.0, 155.0, 172.0]],
),
]
horizon: Annotated[
int,
Field(
ge=1,
le=120,
description="Number of future periods to forecast",
examples=[12],
),
] = 12
alpha: Annotated[
Optional[float],
Field(
gt=0,
le=1,
description="Level smoothing factor α (0 < α ≤ 1). Auto-optimised if not provided.",
examples=[0.3],
),
] = None
beta: Annotated[
Optional[float],
Field(
gt=0,
le=1,
description=(
"Trend smoothing factor β (0 < β ≤ 1). "
"Enables Holt's double exponential smoothing when provided. "
"Auto-optimised together with alpha when both are omitted."
),
examples=[0.1],
),
] = None
confidence_level: Annotated[
float,
Field(
gt=0,
lt=1,
description="Confidence level for prediction intervals",
examples=[0.95],
),
] = 0.95
class BatchForecastRequest(BaseModel):
"""Request body for a batch of forecasts."""
items: Annotated[
List[ForecastRequest],
Field(
min_length=1,
max_length=100,
description="List of individual forecast requests (max 100)",
),
]
|