I am new to FastAPI/model deployment, I managed to created a model which can return a result using the FastAPI docs path in my local server/laptop.
My question is, how can i access this model in jupyter notebook?
Trying to relate into other API request such as Foursquare API. How do I wrap a params dictionary
Tried the following however it is not working
import requests
url = 'http://127.0.0.1:8000/predict'
params = { 'title' : ['Product Operations Software Engineer (DevOps / SRE)']}
result = requests.post(url, params)
<Response [422]>
result.text
'{"detail":[{"loc":["body"],"msg":"value is not a valid dict","type":"type_error.dict"}]}'
My Code
from fastapi import FastAPI
import numpy as np
import dill
import pandas as pd
import uvicorn
import re
from pydantic import BaseModel
app = FastAPI()
class JobTitle(BaseModel):
title: list
#load model
with open("logisticmodel", "rb") as to_load:
logistic_model = dill.load(to_load)
@app.get("/")
def home():
return 'welcome'
@app.post("/predict")
def predict(request: JobTitle):
X = pd.Series(request.title)
result = logistic_model.predict(X)
return {'Type' : list(result) }