Spaces:
Running
Running
Download app.py from Tirush12/personality-api: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/Tirush12/personality-api/resolve/main/app.py
- Command line
-
hf download hf://spaces/Tirush12/personality-api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Tirush12/personality-api/resolve/main/app.py
811 Bytes
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import pandas as pd | |
| import joblib | |
| #Load the model | |
| model = joblib.load('personality_model.pkl') | |
| #Initialize the FastAPI app | |
| app = FastAPI(title="Personality Predictor API") | |
| class UserData(BaseModel): | |
| Time_spent_Alone: float | |
| Stage_fear: str | |
| Social_event_attendance: float | |
| Going_outside: float | |
| Drained_after_socializing: str | |
| Friends_circle_size: float | |
| Post_frequency: float | |
| def home(): | |
| return {"message": "Personality Predictor API is running! Send a POST request to /predict."} | |
| def predict_personality(data: UserData): | |
| input_data = pd.DataFrame([data.dict()]) | |
| prediction = model.predict(input_data)[0] | |
| return {"Prediction": prediction} |