File size: 605 Bytes
be84c47
 
 
 
 
 
 
 
 
3deef8a
be84c47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

from flask import Flask, request, jsonify
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download

# Download model from Hugging Face Model Hub
model_path = hf_hub_download(
    repo_id="AkhilRaja/final-report-best-model",
    filename="best_model.joblib"
)

model = joblib.load(model_path)

app = Flask(__name__)

@app.route("/predict", methods=["POST"])
def predict():
    data = request.json
    df = pd.DataFrame([data])
    prediction = model.predict(df)
    return jsonify({"prediction": int(prediction[0])})

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=7860)