I am using FAST API for my ML Model.
I have a pipeline.
lr_tfidf = Pipeline([('vect', tfidf),
('clf', LogisticRegression(penalty='l2'))])
Now In Fast API, when I want to predict, and display result as API, my code is
app = FastAPI()
@app.post('/predict')
def predict_species(data: str):
data = np.array([data])
prob = lr_tfidf.predict_proba(data).max()
pred = lr_tfidf.predict(data)
return {'Probability': f'{prob}',
'Predictions':f'{pred}'}
I copied it from a tutorial. When I test it on GUI by FASTAPI, it works good as shown in Image, i.e it shows probability and predictions.
When I go to request URL, as provided by the GUI, which is http://127.0.0.1:8000/predict?data=hello (test data is hello) It gives me error.
{"detail":"Method Not Allowed"}
On my Terminal, the error message is
INFO: 127.0.0.1:42568 - "GET /predict?data=hello HTTP/1.1" 405 Method Not Allowed
