This message was deleted.
# announcements
s
This message was deleted.
✅ 1
c
Hi - are you referring to any example notebook you found online?
You may need to add the
--format
option
p
%%writefile uk_data_predict.py import bentoml import fbprophet import pandas as pd from fbprophet import Prophet from bentoml import api, env, artifacts, BentoService from bentoml.adapters import DataframeInput from bentoml.handlers import DataframeHandler from bentoml.artifact import PickleArtifact from bentoml.service.artifacts.common import PickleArtifact @bentoml.artifacts([PickleArtifact('model')]) #custom pickle artifact @env(infer_pip_packages=True) class UKDataPredict (bentoml.BentoService):     @bentoml.api(input=JsonInput(), batch= True)     def predict(self, df: pd.DataFrame):         final_data = df # Figure out the data used for prediction (all rows and all columns)         predictions = self.artifacts.model.predict(final_data)         return predictions.as_data_frame()
c
I see, that notebook was from 0.8.1, and may have some issue with current version of BentoML
cc @Bo @Jiang
b
Will check out the example notebook
c
@PIYUSH AGGARWAL it might be a bug in the JsonInput implementation or the user BentoService code, I don’t think it needs implementing
--format
b
@PIYUSH AGGARWAL Are you expecting Json data for prediction? Right now, the API endpoint is using
JsonInput
and your predict function is set type to pd.DataFrame.
c
the API has changed, it should be
api(input=DataframeInput)
p
I am expecting to feed a dataframe as input for prediction
b
@bentoml.api(input=DataframeInput(), batch=True)
p
!bentoml run UKDataPredict:20201112213619_0DFFD3 predict --input '{"ds":future_data}'
b
Your initial bentoml CLI command is fine Make sure you setup the correct orient for your request JSON data. You can find the orient options here: https://docs.bentoml.org/en/latest/api/adapters.html#dataframeinput
the way BentoML works is it will attempt to convert your incoming data to the data type you expected. For your bento service, you set DatframeInput for your API endpoint. BentoML will attempt to convert incoming data to dataframe format and pass that to your predict function.
You can also pass the csv file as input for CLI. Use the option
—input-file
The csv file will convert to dataframe
p
Yup...I did that before...but the problem is that I am now getting the result as json which is difficult to comprehend...How do I get the output (prediction) in the dataframe format? predictions = self.artifacts.model.predict(final_data) return predictions.to_data_frame() It returns the output in the form of json istelf and predictions = self.artifacts.model.predict(final_data) return predictions.as_data_frame() throws an error