Skip to content

Commit b2d296d

Browse files
committed
Address comments in #1776
1 parent 3c95c53 commit b2d296d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

doc/v2.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ The follow serializer/deserializer classes have been renamed and/or moved:
263263
| ``sagemaker.predictor._JsonDeserializer`` | ``sagemaker.deserializers.JSONDeserializer`` |
264264
+--------------------------------------------------------+-------------------------------------------------------+
265265

266+
``sagemaker.serializers.LibSVMSerializer`` has been added in v2.0.
267+
266268
``distributions``
267269
~~~~~~~~~~~~~~~~~
268270

@@ -325,6 +327,11 @@ TensorFlow Serving Predictor
325327
``sagemaker.tensorflow.serving.Predictor`` has been renamed to :class:`sagemaker.tensorflow.model.TensorFlowPredictor`.
326328
(For the previous implementation of that class, see `Deprecate Legacy TensorFlow <#deprecate-legacy-tensorflow>`_).
327329

330+
XGBoost Predictor
331+
~~~~~~~~~~~~~~~~~
332+
333+
The default seriazlier of ``sagemaker.xgboost.model.XGBoostPredictor`` has been changed from ``NumpySerializer`` to ``LibSVMSerializer``.
334+
328335

329336
Inputs
330337
------

src/sagemaker/serializers.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def CONTENT_TYPE(self):
5454

5555

5656
class CSVSerializer(BaseSerializer):
57-
"""Searilize data of various formats to a CSV-formatted string."""
57+
"""Serialize data of various formats to a CSV-formatted string."""
5858

5959
CONTENT_TYPE = "text/csv"
6060

@@ -102,7 +102,7 @@ def _serialize_row(self, data):
102102
csv_writer.writerow(data)
103103
return csv_buffer.getvalue().rstrip("\r\n")
104104

105-
raise ValueError("Unable to handle input format: ", type(data))
105+
raise ValueError("Unable to handle input format: %s" % type(data))
106106

107107
def _is_sequence_like(self, data):
108108
"""Returns true if obj is iterable and subscriptable."""
@@ -273,7 +273,14 @@ def serialize(self, data):
273273

274274

275275
class LibSVMSerializer(BaseSerializer):
276-
"""Searilize data of various formats to a LibSVM-formatted string."""
276+
"""Serialize data of various formats to a LibSVM-formatted string.
277+
278+
The data must already be in LIBSVM file format:
279+
<label> <index1>:<value1> <index2>:<value2> ...
280+
281+
It is suitable for sparse datasets since it does not store zero-valued
282+
features.
283+
"""
277284

278285
CONTENT_TYPE = "text/libsvm"
279286

@@ -293,4 +300,4 @@ def serialize(self, data):
293300
if hasattr(data, "read"):
294301
return data.read()
295302

296-
raise ValueError("Unable to handle input format: ", type(data))
303+
raise ValueError("Unable to handle input format: %s" % type(data))

0 commit comments

Comments
 (0)