0

I use Amazon Sagemaker for model training and prediction. I have a problem with the returned data with predictions. I am trying to convert prediction data to pandas dataframe format.

After the model is deployed:

from sagemaker.serializers import CSVSerializer

xgb_predictor=estimator.deploy(
    initial_instance_count=1,
    instance_type='ml.g4dn.xlarge',
    serializer=CSVSerializer()
)

I made a prediction on the test data:

predictions=xgb_predictor.predict(first_day.to_numpy())

The returned prediction results are in a binary file

predictions
b'2.092024326324463\n10.584211349487305\n18.23127555847168\n2.092024326324463\n8.308058738708496\n32.35516357421875\n4.129155158996582\n7.429899215698242\n55.65376281738281\n116.5504379272461\n1.0734045505523682\n5.29403018951416\n1.0924320220947266\n1.9484598636627197\n5.29403018951416\n2.190509080886841\n2.085641860961914\n2.092024326324463\n7.674410343170166\n2.1198673248291016\n5.293967247009277\n7.088096618652344\n2.092024326324463\n10.410735130310059\n10.36008358001709\n2.092024326324463\n10.565692901611328\n15.495997428894043\n15.61841106414795\n1.0533703565597534\n6.262670993804932\n31.02411460876465\n10.43086051940918\n3.116995096206665\n3.2846100330352783\n108.82835388183594\n26.210166931152344\n1.0658172369003296\n10.55643367767334\n6.245237350463867\n15.951444625854492\n10.195240020751953\n1.0734045505523682\n48.720497131347656\n2.119992256164551\n9.41071605682373\n2.241959810256958\n3.1907501220703125\n10.415051460266113\n1.2154537439346313\n2.13691782951355\n31.1861515045166\n3.0827555656433105\n6.261478424072266\n5.279026985168457\n15.897627830505371\n20.483125686645508\n20.874958038330078\n53.2086296081543\n10.731611251831055\n2.115110397338867\n13.79739761352539\n2.1198673248291016\n26.628803253173828\n10.030998229980469\n15.897627830505371\n5.278475284576416\n45.371158599853516\n2.2791690826416016\n15.58777141571045\n15.947166442871094\n30.88138771057129\n10.388553619384766\n48.22294235229492\n10.565692901611328\n20.808977127075195\n10.388553619384766\n15.910200119018555\n8.252408981323242\n1.109586238861084\n15.58777141571045\n13.718815803527832\n3.1227424144744873\n32.171592712402344\n10.524396896362305\n15.897627830505371\n2.092024326324463\n14.52088737487793\n5.293967247009277\n57.61208724975586\n21.161712646484375\n14.173937797546387\n5.230247974395752\n16.257652282714844

How can I convert prediction data to pandas dataframe?

1 Answer 1

0

you mean this:

import pandas as pd

a = a.decode(encoding="utf-8").split("\n")

df = pd.DataFrame(data=a)
df.head()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.