File size: 452 Bytes
ff52cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from fastapi import FastAPI
from pydantic import BaseModel
import joblib

app = FastAPI()

# Load model and vectorizer
model = joblib.load("final_model.pkl")
vectorizer = joblib.load("tfidf_vectorizer.pkl")

class InputData(BaseModel):
    purpose_text: str

@app.post("/classify")
def classify(data: InputData):
    vec = vectorizer.transform([data.purpose_text])
    pred = model.predict(vec)[0]
    return {"predicted_type": pred}