Spaces:
Sleeping
Sleeping
Clear space for fresh deployment
Browse files- app/schemas.py +0 -80
app/schemas.py
DELETED
|
@@ -1,80 +0,0 @@
|
|
| 1 |
-
"""Pydantic request/response models."""
|
| 2 |
-
from __future__ import annotations
|
| 3 |
-
from pydantic import BaseModel, Field, ConfigDict
|
| 4 |
-
from typing import Optional
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
class BookingFeatures(BaseModel):
|
| 8 |
-
"""Public prediction payload schema.
|
| 9 |
-
|
| 10 |
-
Many training-time features are internal or engineered; to keep the public
|
| 11 |
-
contract lightweight we make several fields optional with neutral defaults.
|
| 12 |
-
This enables a *minimal* JSON payload such as:
|
| 13 |
-
{"lead_time": 30, "arrival_month": 7, "adults": 2, "children": 0, "adr": 120.0}
|
| 14 |
-
The `_prepare` function supplements / engineers the remaining columns.
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
-
lead_time: int = Field(..., ge=0)
|
| 18 |
-
arrival_month: int = Field(..., ge=1, le=12)
|
| 19 |
-
# Stay details (optional, defaulting to a short weekday stay)
|
| 20 |
-
stays_weekend_nights: int | None = Field(0, ge=0)
|
| 21 |
-
stays_week_nights: int | None = Field(1, ge=0)
|
| 22 |
-
# Guest composition
|
| 23 |
-
adults: int = Field(..., ge=1)
|
| 24 |
-
children: int | None = Field(0, ge=0)
|
| 25 |
-
# Historical / behavioral signals
|
| 26 |
-
is_repeated_guest: int | None = Field(0, ge=0, le=1)
|
| 27 |
-
previous_cancellations: int | None = Field(0, ge=0)
|
| 28 |
-
booking_changes: int | None = Field(0, ge=0)
|
| 29 |
-
# Pricing
|
| 30 |
-
adr: float = Field(..., ge=0, description="Average daily rate (numeric, required)")
|
| 31 |
-
# Amenities / request counts
|
| 32 |
-
required_car_parking_spaces: int | None = Field(0, ge=0)
|
| 33 |
-
total_of_special_requests: int | None = Field(0, ge=0)
|
| 34 |
-
|
| 35 |
-
model_config = ConfigDict(json_schema_extra={
|
| 36 |
-
"examples": [
|
| 37 |
-
{
|
| 38 |
-
"summary": "Minimal",
|
| 39 |
-
"value": {
|
| 40 |
-
"lead_time": 30,
|
| 41 |
-
"arrival_month": 7,
|
| 42 |
-
"adults": 2,
|
| 43 |
-
"children": 0,
|
| 44 |
-
"adr": 120.0
|
| 45 |
-
}
|
| 46 |
-
},
|
| 47 |
-
{
|
| 48 |
-
"summary": "Extended",
|
| 49 |
-
"value": {
|
| 50 |
-
"lead_time": 120,
|
| 51 |
-
"arrival_month": 7,
|
| 52 |
-
"stays_weekend_nights": 2,
|
| 53 |
-
"stays_week_nights": 3,
|
| 54 |
-
"adults": 2,
|
| 55 |
-
"children": 1,
|
| 56 |
-
"is_repeated_guest": 0,
|
| 57 |
-
"previous_cancellations": 0,
|
| 58 |
-
"booking_changes": 1,
|
| 59 |
-
"adr": 95.5,
|
| 60 |
-
"required_car_parking_spaces": 0,
|
| 61 |
-
"total_of_special_requests": 2
|
| 62 |
-
}
|
| 63 |
-
}
|
| 64 |
-
]
|
| 65 |
-
})
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
class PredictionResponse(BaseModel):
|
| 69 |
-
prediction: int
|
| 70 |
-
probability: float
|
| 71 |
-
model_version: str | None = None
|
| 72 |
-
applied_threshold: float | None = None
|
| 73 |
-
threshold_source: str | None = None
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
class HealthResponse(BaseModel):
|
| 77 |
-
status: str
|
| 78 |
-
model_loaded: bool
|
| 79 |
-
model_version: Optional[str] = None
|
| 80 |
-
decision_threshold: Optional[float] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|