Scikit Learn — sagemaker 2.199.0 documentation (original) (raw)

sagemaker

Scikit Learn Estimator

class sagemaker.sklearn.estimator. SKLearn(entry_point, framework_version=None, py_version='py3', source_dir=None, hyperparameters=None, image_uri=None, image_uri_region=None, **kwargs)

Bases: sagemaker.estimator.Framework

Handle end-to-end training and deployment of custom Scikit-learn code.

Creates a SKLearn Estimator for Scikit-learn environment.

It will execute an Scikit-learn script within a SageMaker Training Job. The managed Scikit-learn environment is an Amazon-built Docker container that executes functions defined in the supplied entry_point Python script.

Training is started by callingfit() on this Estimator. After training is complete, callingdeploy() creates a hosted SageMaker endpoint and returns anSKLearnPredictor instance that can be used to perform inference against the hosted model.

Technical documentation on preparing Scikit-learn scripts for SageMaker training and using the Scikit-learn Estimator is available on the project home-page: https://github.com/aws/sagemaker-python-sdk

Parameters

create_model(model_server_workers=None, role=None, vpc_config_override='VPC_CONFIG_DEFAULT', entry_point=None, source_dir=None, dependencies=None, **kwargs)

Create a SageMaker SKLearnModel object that can be deployed to an Endpoint.

Parameters

Returns

A SageMaker SKLearnModelobject. See SKLearnModel() for full details.

Return type

sagemaker.sklearn.model.SKLearnModel

Scikit Learn Model

class sagemaker.sklearn.model. SKLearnModel(model_data, role=None, entry_point=None, framework_version=None, py_version='py3', image_uri=None, predictor_cls=<class 'sagemaker.sklearn.model.SKLearnPredictor'>, model_server_workers=None, **kwargs)

Bases: sagemaker.model.FrameworkModel

An Scikit-learn SageMaker Model that can be deployed to a SageMaker Endpoint.

Initialize an SKLearnModel.

Parameters

Tip

You can find additional parameters for initializing this class atFrameworkModel andModel.

register(content_types=None, response_types=None, inference_instances=None, transform_instances=None, model_package_name=None, model_package_group_name=None, image_uri=None, model_metrics=None, metadata_properties=None, marketplace_cert=False, approval_status=None, description=None, drift_check_baselines=None, customer_metadata_properties=None, domain=None, sample_payload_url=None, task=None, framework=None, framework_version=None, nearest_model_name=None, data_input_configuration=None, skip_model_validation=None)

Creates a model package for creating SageMaker models or listing on Marketplace.

Parameters

Returns

A sagemaker.model.ModelPackage instance.

prepare_container_def(instance_type=None, accelerator_type=None, serverless_inference_config=None)

Container definition with framework configuration set in model environment variables.

Parameters

Returns

A container definition object usable with the CreateModel API.

Return type

dict[str, str]

serving_image_uri(region_name, instance_type, serverless_inference_config=None)

Create a URI for the serving image.

Parameters

Returns

The appropriate image URI based on the given parameters.

Return type

str

Scikit Learn Predictor

class sagemaker.sklearn.model. SKLearnPredictor(endpoint_name, sagemaker_session=None, serializer=<sagemaker.base_serializers.NumpySerializer object>, deserializer=<sagemaker.base_deserializers.NumpyDeserializer object>, component_name=None)

Bases: sagemaker.base_predictor.Predictor

A Predictor for inference against Scikit-learn Endpoints.

This is able to serialize Python lists, dictionaries, and numpy arrays to multidimensional tensors for Scikit-learn inference.

Initialize an SKLearnPredictor.

Parameters

Scikit Learn Processor

class sagemaker.sklearn.processing. SKLearnProcessor(framework_version, role=None, instance_count=None, instance_type=None, command=None, volume_size_in_gb=30, volume_kms_key=None, output_kms_key=None, max_runtime_in_seconds=None, base_job_name=None, sagemaker_session=None, env=None, tags=None, network_config=None)

Bases: sagemaker.processing.ScriptProcessor

Handles Amazon SageMaker processing tasks for jobs using scikit-learn.

Initialize an SKLearnProcessor instance.

The SKLearnProcessor handles Amazon SageMaker processing tasks for jobs using scikit-learn.

Parameters