"""A simple API to expose our trained RandomForest model for Tutanic survival.""" from fastapi import FastAPI from joblib import load import pandas as pd from getdvf import download_file download_file("https://minio.lab.sspcloud.fr/projet-formation/diffusion/python-datascientist/pipe.joblib", 'pipe.joblib') model = load('pipe.joblib') app = FastAPI( title="Quel est le prix de ce logement ?", description= "Application du boosting sur les données DVF 🏡
Une version par API pour faciliter la réutilisation du modèle 🚀" +\ "

" ) @app.get("/", tags=["Welcome"]) def show_welcome_page(): """ Show welcome page with model name and version. """ return { "Message": "API de prédiction des prix de l'immobilier", "Model_name": 'DVF ML', "Model_version": "0.1", } @app.get("/predict", tags=["Predict"]) async def predict( month: int = 3, nombre_lots: int = 1, code_type_local: int = 2, nombre_pieces_principales: int = 3, surface: float = 75 ) -> float: """ """ df = pd.DataFrame( { "month": [month], "Nombre_de_lots": [nombre_lots], "Code_type_local": [code_type_local], "Nombre_pieces_principales": [nombre_pieces_principales], "surface": [surface] } ) prediction = model.predict(df) return prediction