Skip to content

Commit

Permalink
feat(challenges): [api] add implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
msmendoza committed Feb 27, 2025
1 parent 036f95d commit a77e1af
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 344 deletions.
14 changes: 12 additions & 2 deletions challenge/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import fastapi
import joblib
import pandas as pd
from fastapi import Request
from fastapi.responses import JSONResponse
from sklearn.linear_model import LogisticRegression


app = fastapi.FastAPI()
Expand All @@ -10,5 +15,10 @@ async def get_health() -> dict:


@app.post("/predict", status_code=200)
async def post_predict() -> dict:
return
async def post_predict(req: Request) -> JSONResponse:
features = pd.DataFrame((await req.json())["flights"])

model: LogisticRegression = joblib.load("data/model.joblib")
model.predict(features)

return JSONResponse(content={"predictions": features.to_dict()})
707 changes: 365 additions & 342 deletions challenge/exploration.ipynb

Large diffs are not rendered by default.

Binary file added data/reg_model.pkl
Binary file not shown.
2 changes: 2 additions & 0 deletions docs/challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ repo and this repo only updates associated Docker images.
1. `training_data` var was not being used.
2. Although some better cols where found after some improvements I left the ones fixed in the
tests.
3. I chosed the Logistic Regression model because it is a simple model in comparison to the
XGBoost model and performances are pretty similar > low processing costs.

0 comments on commit a77e1af

Please sign in to comment.