'XGBoost Sagemaker model fits but won't predict
Using the Sagemaker built in xgboost model I am able to fit the model on the training and validation data, and successfully deploy it as an endpoint.
# Creating deployable object of the model
predictor = estimator.deploy(initial_instance_count = 1,
instance_type = 'ml.m4.xlarge',
endpoint_name = 'endpoint')
# Setup before predictions
predictor.serializer = CSVSerializer()
# Connecting to the endpoint previously deployed
endpoint_name = 'endpoint'
predictor = sagemaker.predictor.Predictor(endpoint_name = endpoint_name)
# Converting test file to be passed
arr_test = test.values
# arr_test = arr_test.tobytes()
print(arr_test)
When I go to call on this endpoint and use the .predict() method, I'm thrown the following error.
I have tried switching the input array to bytes, but am also getting another error when I do that (shown in the screenshot below). I am following an example from a Udemy course which uses the exact same method, but I am applying it to a personal dataset which was extracted from an RDS file, then converted into a dataframe and into a csv from that 
Solution 1:[1]
Have you tried to append the predict with a decode("utf-8") ?
eg:
result = predictor.predict(arr_test[:1]).decode("utf-8")
Please post back or vote if it fixes the problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jonr |
