You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/frameworks/sklearn/using_sklearn.rst
+25-18Lines changed: 25 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ With Scikit-learn Estimators, you can train and host Scikit-learn models on Amaz
7
7
For information about supported versions of Scikit-learn, see the `AWS documentation <https://docs.aws.amazon.com/sagemaker/latest/dg/sklearn.html>`__.
8
8
We recommend that you use the latest supported version because that's where we focus most of our development efforts.
9
9
10
-
You can visit the Scikit-learn repository at https://github.com/scikit-learn/scikit-learn.
10
+
For more information about the framework, see the `Sciket-Learn <https://github.com/scikit-learn/scikit-learn>`_ repository.
11
11
For general information about using the SageMaker Python SDK, see :ref:`overview:Using the SageMaker Python SDK`.
12
12
13
13
.. contents::
@@ -82,7 +82,8 @@ Because the SageMaker imports your training script, you should put your training
82
82
(``if __name__=='__main__':``) if you are using the same script to host your model, so that SageMaker does not
83
83
inadvertently run your training code at the wrong point in execution.
84
84
85
-
For more on training environment variables, please visit https://github.com/aws/sagemaker-containers.
85
+
For more on training environment variables, please visit
86
+
`SageMaker Training Toolkit <https://github.com/aws/sagemaker-training-toolkit>`_.
86
87
87
88
.. important::
88
89
The sagemaker-containers repository has been deprecated,
@@ -124,7 +125,7 @@ Both ``requirements.txt`` and your training script should be put in the same fol
124
125
You must specify this folder in ``source_dir`` argument when creating a Scikit-learn estimator.
125
126
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``.
126
127
You can also specify the version of an item to install.
127
-
For information about the format of a ``requirements.txt`` file, see `Requirements Files <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`__ in the pip documentation.
128
+
For information about the format of a ``requirements.txt`` file, see `Requirements Files <https://pip.pypa.io/en/stable/user_guide#requirements-files>`__ in the pip documentation.
128
129
129
130
Create an Estimator
130
131
===================
@@ -241,7 +242,8 @@ Before a model can be served, it must be loaded. The SageMaker Scikit-learn mode
241
242
242
243
.. code:: python
243
244
244
-
defmodel_fn(model_dir)
245
+
defmodel_fn(model_dir):
246
+
...
245
247
246
248
SageMaker will inject the directory where your model files and sub-directories, saved by ``save``, have been mounted.
247
249
Your model function should return a model object that can be used for model serving.
@@ -334,14 +336,16 @@ it should return an object that can be passed to ``predict_fn`` and have the fol
334
336
335
337
.. code:: python
336
338
337
-
definput_fn(request_body, request_content_type)
339
+
definput_fn(request_body, request_content_type):
340
+
...
338
341
339
-
Where ``request_body`` is a byte buffer and ``request_content_type`` is a Python string
342
+
where ``request_body`` is a byte buffer and ``request_content_type`` is a Python string.
340
343
341
344
The SageMaker Scikit-learn model server provides a default implementation of ``input_fn``.
342
345
This function deserializes JSON, CSV, or NPY encoded data into a NumPy array.
343
346
344
-
Default NPY deserialization requires ``request_body`` to follow the `NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format. For Scikit-learn, the Python SDK
347
+
Default NPY deserialization requires ``request_body`` to follow the
348
+
`NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format. For Scikit-learn, the Python SDK
345
349
defaults to sending prediction requests with this format.
346
350
347
351
Default json deserialization requires ``request_body`` contain a single json list.
@@ -383,7 +387,8 @@ The ``predict_fn`` function has the following signature:
383
387
384
388
.. code:: python
385
389
386
-
defpredict_fn(input_object, model)
390
+
defpredict_fn(input_object, model):
391
+
...
387
392
388
393
Where ``input_object`` is the object returned from ``input_fn`` and
389
394
``model`` is the model loaded by ``model_fn``.
@@ -426,7 +431,8 @@ The ``output_fn`` has the following signature:
426
431
427
432
.. code:: python
428
433
429
-
defoutput_fn(prediction, content_type)
434
+
defoutput_fn(prediction, content_type):
435
+
...
430
436
431
437
Where ``prediction`` is the result of invoking ``predict_fn`` and
432
438
``content_type`` is the InvokeEndpoint requested response content-type.
@@ -481,38 +487,39 @@ To see what arguments are accepted by the ``SKLearnModel`` constructor, see :cla
481
487
Your model data must be a .tar.gz file in S3. SageMaker Training Job model data is saved to .tar.gz files in S3,
482
488
however if you have local data you want to deploy, you can prepare the data yourself.
483
489
484
-
Assuming you have a local directory containg your model data named "my_model" you can tar and gzip compress the file and
490
+
Assuming you have a local directory containing your model data named "my_model", you can tar and gzip compress the file and
These are also available in SageMaker Notebook Instance hosted Jupyter notebooks under the "sample notebooks" folder.
507
513
508
514
******************************
509
-
SageMaker scikit-learn Classes
515
+
SageMaker Scikit-learn Classes
510
516
******************************
511
517
512
-
For information about the different scikit-learn classes in the SageMaker Python SDK, see https://sagemaker.readthedocs.io/en/stable/frameworks/sklearn/sagemaker.sklearn.html.
518
+
For information about the different Scikit-learn classes in the SageMaker Python SDK, see https://sagemaker.readthedocs.io/en/stable/frameworks/sklearn/sagemaker.sklearn.html.
513
519
514
520
****************************************
515
521
SageMaker Scikit-learn Docker Containers
516
522
****************************************
517
523
518
-
You can visit the SageMaker Scikit-Learn containers repository here: https://github.com/aws/sagemaker-scikit-learn-container
524
+
To find the SageMaker-managed Scikit-learn containers,
525
+
visit the `SageMaker Scikit-Learn containers repository <https://github.com/aws/sagemaker-scikit-learn-container>`_.
0 commit comments