2 Answers
- Newest
- Most votes
- Most comments
0
Since the error is occuring in the call to libsvm_to_dmatrix(), the content type is set to "text/csv". Have you tried passing in a csv string?
0
You appear to have conflicting data types in your input_fn
:
if request_content_type == "text/csv": print("request body", request_body) # change to request_body to Pandas DataFrame return xgb_encoders.libsvm_to_dmatrix(request_body) #perform encoding on the input data here
Probably the logic you want is:
if request_content_type == "text/csv": return xgb_encoders.csv_to_dmatrix(request_body) elif request_content_type == "text/libsvm": return xgb_encoders.libsvm_to_dmatrix(request_body)
answered 2 years ago
@TulioAlberto
Yes, I tried
csv_to_dmatrix
method as well. Here's what I got:exception on /invocations [POST] 2m0f5t1bx9-algo-1-6cj3i | Traceback (most recent call last): 2m0f5t1bx9-algo-1-6cj3i | File "/miniconda3/lib/python3.6/site-packages/scipy/sparse/base.py", line 327, in asformat 2m0f5t1bx9-algo-1-6cj3i | return convert_method(copy=copy) 2m0f5t1bx9-algo-1-6cj3i | File "/miniconda3/lib/python3.6/site-packages/scipy/sparse/coo.py", line 400, in tocsr 2m0f5t1bx9-algo-1-6cj3i | data = np.empty_like(self.data, dtype=upcast(self.dtype)) 2m0f5t1bx9-algo-1-6cj3i | File "/miniconda3/lib/python3.6/site-packages/scipy/sparse/sputils.py", line 52, in upcast 2m0f5t1bx9-algo-1-6cj3i | raise TypeError('no supported conversion for types: %r' % (args,)) 2m0f5t1bx9-algo-1-6cj3i | TypeError: no supported conversion for types: (dtype('O'),) During handling of the above exception, another exception occurred: 2m0f5t1bx9-algo-1-6cj3i | 2m0f5t1bx9-algo-1-6cj3i | Traceback (most recent call last): 2m0f5t1bx9-algo-1-6cj3i | File "/miniconda3/lib/python3.6/site-packages/sagemaker_containers/_functions.py", line 93, in wrapper 2m0f5t1bx9-algo-1-6cj3i | return fn(*args, **kwargs) 2m0f5t1bx9-algo-1-6cj3i | File "/opt/ml/code/inference.py", line 75, in predict_fn 2m0f5t1bx9-algo-1-6cj3i | prediction = model.predict(input_data) 2m0f5t1bx9-algo-1-6cj3i | File "/miniconda3/lib/python3.6/site-packages/xgboost/sklearn.py", line 448, in pre
Relevant content
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
@amiller yes, I have tried passing a string a float. Sample request body:
208,143,171,136,206,127,0,0,64,162
@amiller I tried using passing the test data point as a numpy array and modified the
def input_fn
function to accept numpy array. However, it is still not working.