Spaces:
Sleeping
Sleeping
Edit des class
Browse files
app.py
CHANGED
|
@@ -34,44 +34,21 @@ MODEL = None
|
|
| 34 |
# -----------------------------------------------------------------------------
|
| 35 |
# FastAPI Setup
|
| 36 |
# -----------------------------------------------------------------------------
|
| 37 |
-
app = FastAPI(title="
|
| 38 |
|
| 39 |
|
| 40 |
class PredictionFeatures(BaseModel):
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
HourlyRate: Union[int, float]
|
| 53 |
-
JobInvolvement: Union[int, float]
|
| 54 |
-
JobLevel: Union[int, float]
|
| 55 |
-
JobRole: str
|
| 56 |
-
JobSatisfaction: Union[int, float]
|
| 57 |
-
MaritalStatus: str
|
| 58 |
-
MonthlyIncome: Union[int, float]
|
| 59 |
-
MonthlyRate: Union[int, float]
|
| 60 |
-
NumCompaniesWorked: Union[int, float]
|
| 61 |
-
Over18: str
|
| 62 |
-
OverTime: str
|
| 63 |
-
PercentSalaryHike: Union[int, float]
|
| 64 |
-
PerformanceRating: Union[int, float]
|
| 65 |
-
RelationshipSatisfaction: Union[int, float]
|
| 66 |
-
StandardHours: Union[int, float]
|
| 67 |
-
StockOptionLevel: Union[int, float]
|
| 68 |
-
TotalWorkingYears: Union[int, float]
|
| 69 |
-
TrainingTimesLastYear: Union[int, float]
|
| 70 |
-
WorkLifeBalance: Union[int, float]
|
| 71 |
-
YearsAtCompany: Union[int, float]
|
| 72 |
-
YearsInCurrentRole: Union[int, float]
|
| 73 |
-
YearsSinceLastPromotion: Union[int, float]
|
| 74 |
-
YearsWithCurrManager: Union[int, float]
|
| 75 |
|
| 76 |
|
| 77 |
# -----------------------------------------------------------------------------
|
|
@@ -84,7 +61,7 @@ def load_model_sync():
|
|
| 84 |
try:
|
| 85 |
# On attend que le chargement soit fini avant de rendre l'API disponible
|
| 86 |
MODEL = mlflow.sklearn.load_model(MODEL_URI)
|
| 87 |
-
# models:/
|
| 88 |
print("β
[INFO] Model loaded successfully!")
|
| 89 |
except Exception as e:
|
| 90 |
print(f"β [ERROR] Failed to load model: {e}")
|
|
@@ -118,4 +95,4 @@ async def predict(payload: PredictionFeatures):
|
|
| 118 |
|
| 119 |
if __name__ == "__main__":
|
| 120 |
# Port 7860 est le standard pour Hugging Face Spaces
|
| 121 |
-
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))
|
|
|
|
| 34 |
# -----------------------------------------------------------------------------
|
| 35 |
# FastAPI Setup
|
| 36 |
# -----------------------------------------------------------------------------
|
| 37 |
+
app = FastAPI(title="π¬οΈ Wind Turbine Prediction API")
|
| 38 |
|
| 39 |
|
| 40 |
class PredictionFeatures(BaseModel):
|
| 41 |
+
Hour_Index: Union[int, float]
|
| 42 |
+
Turbine_ID: int
|
| 43 |
+
Rotor_Speed_RPM: float
|
| 44 |
+
Wind_Speed_mps: float
|
| 45 |
+
Power_Output_kW: float
|
| 46 |
+
Gearbox_Oil_Temp_C: float
|
| 47 |
+
Generator_Bearing_Temp_C: float
|
| 48 |
+
Vibration_Level_mmps: float
|
| 49 |
+
Ambient_Temp_C: float
|
| 50 |
+
Humidity_pct: float
|
| 51 |
+
Maintenance_Label: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
# -----------------------------------------------------------------------------
|
|
|
|
| 61 |
try:
|
| 62 |
# On attend que le chargement soit fini avant de rendre l'API disponible
|
| 63 |
MODEL = mlflow.sklearn.load_model(MODEL_URI)
|
| 64 |
+
# models:/wind_turbine_predictor@production
|
| 65 |
print("β
[INFO] Model loaded successfully!")
|
| 66 |
except Exception as e:
|
| 67 |
print(f"β [ERROR] Failed to load model: {e}")
|
|
|
|
| 95 |
|
| 96 |
if __name__ == "__main__":
|
| 97 |
# Port 7860 est le standard pour Hugging Face Spaces
|
| 98 |
+
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))
|