You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::MachineLearning::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::MachineLearning::Client
- Defined in:
- (unknown)
Overview
An API client for Amazon Machine Learning. To construct a client, you need to configure a :region and :credentials.
machinelearning = Aws::MachineLearning::Client.new(
region: region_name,
credentials: credentials,
# ...
)
See #initialize for a full list of supported configuration options.
Region
You can configure a default region in the following locations:
ENV['AWS_REGION']Aws.config[:region]
Go here for a list of supported regions.
Credentials
Default credentials are loaded automatically from the following locations:
ENV['AWS_ACCESS_KEY_ID']andENV['AWS_SECRET_ACCESS_KEY']Aws.config[:credentials]- The shared credentials ini file at
~/.aws/credentials(more information) - From an instance profile when running on EC2
You can also construct a credentials object from one of the following classes:
Alternatively, you configure credentials with :access_key_id and
:secret_access_key:
# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))
Aws::MachineLearning::Client.new(
access_key_id: creds['access_key_id'],
secret_access_key: creds['secret_access_key']
)
Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.
Attribute Summary collapse
Instance Attribute Summary
Attributes inherited from Seahorse::Client::Base
Constructor collapse
-
#initialize(options = {}) ⇒ Aws::MachineLearning::Client
constructor
Constructs an API client.
API Operations collapse
-
#add_tags(options = {}) ⇒ Types::AddTagsOutput
Adds one or more tags to an object, up to a limit of 10.
-
#create_batch_prediction(options = {}) ⇒ Types::CreateBatchPredictionOutput
Generates predictions for a group of observations.
-
#create_data_source_from_rds(options = {}) ⇒ Types::CreateDataSourceFromRDSOutput
Creates a
DataSourceobject from an Amazon Relational Database Service (Amazon RDS). -
#create_data_source_from_redshift(options = {}) ⇒ Types::CreateDataSourceFromRedshiftOutput
Creates a
DataSourcefrom a database hosted on an Amazon Redshift cluster. -
#create_data_source_from_s3(options = {}) ⇒ Types::CreateDataSourceFromS3Output
Creates a
DataSourceobject. -
#create_evaluation(options = {}) ⇒ Types::CreateEvaluationOutput
Creates a new
Evaluationof anMLModel. -
#create_ml_model(options = {}) ⇒ Types::CreateMLModelOutput
Creates a new
MLModelusing theDataSourceand the recipe as information sources. -
#create_realtime_endpoint(options = {}) ⇒ Types::CreateRealtimeEndpointOutput
Creates a real-time endpoint for the
MLModel. -
#delete_batch_prediction(options = {}) ⇒ Types::DeleteBatchPredictionOutput
Assigns the DELETED status to a
BatchPrediction, rendering it unusable.After using the
DeleteBatchPredictionoperation, you can use the GetBatchPrediction operation to verify that the status of theBatchPredictionchanged to DELETED.Caution: The result of the
.DeleteBatchPredictionoperation is irreversible. -
#delete_data_source(options = {}) ⇒ Types::DeleteDataSourceOutput
Assigns the DELETED status to a
DataSource, rendering it unusable.After using the
DeleteDataSourceoperation, you can use the GetDataSource operation to verify that the status of theDataSourcechanged to DELETED.Caution: The results of the
.DeleteDataSourceoperation are irreversible. -
#delete_evaluation(options = {}) ⇒ Types::DeleteEvaluationOutput
Assigns the
DELETEDstatus to anEvaluation, rendering it unusable.After invoking the
DeleteEvaluationoperation, you can use theGetEvaluationoperation to verify that the status of theEvaluationchanged toDELETED. .Caution The results of the
DeleteEvaluationoperation are irreversible. -
#delete_ml_model(options = {}) ⇒ Types::DeleteMLModelOutput
Assigns the
DELETEDstatus to anMLModel, rendering it unusable.After using the
DeleteMLModeloperation, you can use theGetMLModeloperation to verify that the status of theMLModelchanged to DELETED.Caution: The result of the
.DeleteMLModeloperation is irreversible. -
#delete_realtime_endpoint(options = {}) ⇒ Types::DeleteRealtimeEndpointOutput
Deletes a real time endpoint of an
MLModel..
-
#delete_tags(options = {}) ⇒ Types::DeleteTagsOutput
Deletes the specified tags associated with an ML object.
-
#describe_batch_predictions(options = {}) ⇒ Types::DescribeBatchPredictionsOutput
Returns a list of
BatchPredictionoperations that match the search criteria in the request..
-
#describe_data_sources(options = {}) ⇒ Types::DescribeDataSourcesOutput
Returns a list of
DataSourcethat match the search criteria in the request..
-
#describe_evaluations(options = {}) ⇒ Types::DescribeEvaluationsOutput
Returns a list of
DescribeEvaluationsthat match the search criteria in the request..
-
#describe_ml_models(options = {}) ⇒ Types::DescribeMLModelsOutput
Returns a list of
MLModelthat match the search criteria in the request..
-
#describe_tags(options = {}) ⇒ Types::DescribeTagsOutput
Describes one or more of the tags for your Amazon ML object.
.
-
#get_batch_prediction(options = {}) ⇒ Types::GetBatchPredictionOutput
Returns a
BatchPredictionthat includes detailed metadata, status, and data file information for aBatch Predictionrequest..
-
#get_data_source(options = {}) ⇒ Types::GetDataSourceOutput
Returns a
DataSourcethat includes metadata and data file information, as well as the current status of theDataSource.GetDataSourceprovides results in normal or verbose format. -
#get_evaluation(options = {}) ⇒ Types::GetEvaluationOutput
Returns an
Evaluationthat includes metadata as well as the current status of theEvaluation..
-
#get_ml_model(options = {}) ⇒ Types::GetMLModelOutput
Returns an
MLModelthat includes detailed metadata, data source information, and the current status of theMLModel.GetMLModelprovides results in normal or verbose format. -
#predict(options = {}) ⇒ Types::PredictOutput
Generates a prediction for the observation using the specified
ML Model.Note Not all response parameters will be populated.
-
#update_batch_prediction(options = {}) ⇒ Types::UpdateBatchPredictionOutput
Updates the
BatchPredictionNameof aBatchPrediction.You can use the
.GetBatchPredictionoperation to view the contents of the updated data element. -
#update_data_source(options = {}) ⇒ Types::UpdateDataSourceOutput
Updates the
DataSourceNameof aDataSource.You can use the
.GetDataSourceoperation to view the contents of the updated data element. -
#update_evaluation(options = {}) ⇒ Types::UpdateEvaluationOutput
Updates the
EvaluationNameof anEvaluation.You can use the
.GetEvaluationoperation to view the contents of the updated data element. -
#update_ml_model(options = {}) ⇒ Types::UpdateMLModelOutput
Updates the
MLModelNameand theScoreThresholdof anMLModel.You can use the
.GetMLModeloperation to view the contents of the updated data element.
Instance Method Summary collapse
-
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
-
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters.
Methods inherited from Seahorse::Client::Base
add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options = {}) ⇒ Aws::MachineLearning::Client
Constructs an API client.
Instance Method Details
#add_tags(options = {}) ⇒ Types::AddTagsOutput
Adds one or more tags to an object, up to a limit of 10. Each tag consists of a key and an optional value. If you add a tag using a key that is already associated with the ML object, AddTags updates the tag's value.
#create_batch_prediction(options = {}) ⇒ Types::CreateBatchPredictionOutput
Generates predictions for a group of observations. The observations to process exist in one or more data files referenced by a DataSource. This operation creates a new BatchPrediction, and uses an MLModel and the data files referenced by the DataSource as information sources.
CreateBatchPrediction is an asynchronous operation. In response to CreateBatchPrediction, Amazon Machine Learning (Amazon ML) immediately returns and sets the BatchPrediction status to PENDING. After the BatchPrediction completes, Amazon ML sets the status to COMPLETED.
You can poll for status updates by using the GetBatchPrediction operation and checking the Status parameter of the result. After the COMPLETED status appears, the results are available in the location specified by the OutputUri parameter.
#create_data_source_from_rds(options = {}) ⇒ Types::CreateDataSourceFromRDSOutput
Creates a DataSource object from an Amazon Relational Database Service (Amazon RDS). A DataSource references data that can be used to perform CreateMLModel, CreateEvaluation, or CreateBatchPrediction operations.
CreateDataSourceFromRDS is an asynchronous operation. In response to CreateDataSourceFromRDS, Amazon Machine Learning (Amazon ML) immediately returns and sets the DataSource status to PENDING. After the DataSource is created and ready for use, Amazon ML sets the Status parameter to COMPLETED. DataSource in the COMPLETED or PENDING state can be used only to perform >CreateMLModel>, CreateEvaluation, or CreateBatchPrediction operations.
If Amazon ML cannot accept the input source, it sets the Status parameter to FAILED and includes an error message in the Message attribute of the GetDataSource operation response.
#create_data_source_from_redshift(options = {}) ⇒ Types::CreateDataSourceFromRedshiftOutput
Creates a DataSource from a database hosted on an Amazon Redshift cluster. A DataSource references data that can be used to perform either CreateMLModel, CreateEvaluation, or CreateBatchPrediction operations.
CreateDataSourceFromRedshift is an asynchronous operation. In response to CreateDataSourceFromRedshift, Amazon Machine Learning (Amazon ML) immediately returns and sets the DataSource status to PENDING. After the DataSource is created and ready for use, Amazon ML sets the Status parameter to COMPLETED. DataSource in COMPLETED or PENDING states can be used to perform only CreateMLModel, CreateEvaluation, or CreateBatchPrediction operations.
If Amazon ML can't accept the input source, it sets the Status parameter to FAILED and includes an error message in the Message attribute of the GetDataSource operation response.
The observations should be contained in the database hosted on an Amazon Redshift cluster and should be specified by a SelectSqlQuery query. Amazon ML executes an Unload command in Amazon Redshift to transfer the result set of the SelectSqlQuery query to S3StagingLocation.
After the DataSource has been created, it's ready for use in evaluations and batch predictions. If you plan to use the DataSource to train an MLModel, the DataSource also requires a recipe. A recipe describes how each input variable will be used in training an MLModel. Will the variable be included or excluded from training? Will the variable be manipulated; for example, will it be combined with another variable or will it be split apart into word combinations? The recipe provides answers to these questions.
You can't change an existing datasource, but you can copy and modify the settings from an existing Amazon Redshift datasource to create a new datasource. To do so, call GetDataSource for an existing datasource and copy the values to a CreateDataSource call. Change the settings that you want to change and make sure that all required fields have the appropriate values.
#create_data_source_from_s3(options = {}) ⇒ Types::CreateDataSourceFromS3Output
Creates a DataSource object. A DataSource references data that can be used to perform CreateMLModel, CreateEvaluation, or CreateBatchPrediction operations.
CreateDataSourceFromS3 is an asynchronous operation. In response to CreateDataSourceFromS3, Amazon Machine Learning (Amazon ML) immediately returns and sets the DataSource status to PENDING. After the DataSource has been created and is ready for use, Amazon ML sets the Status parameter to COMPLETED. DataSource in the COMPLETED or PENDING state can be used to perform only CreateMLModel, CreateEvaluation or CreateBatchPrediction operations.
If Amazon ML can't accept the input source, it sets the Status parameter to FAILED and includes an error message in the Message attribute of the GetDataSource operation response.
The observation data used in a DataSource should be ready to use; that is, it should have a consistent structure, and missing data values should be kept to a minimum. The observation data must reside in one or more .csv files in an Amazon Simple Storage Service (Amazon S3) location, along with a schema that describes the data items by name and type. The same schema must be used for all of the data files referenced by the DataSource.
After the DataSource has been created, it's ready to use in evaluations and batch predictions. If you plan to use the DataSource to train an MLModel, the DataSource also needs a recipe. A recipe describes how each input variable will be used in training an MLModel. Will the variable be included or excluded from training? Will the variable be manipulated; for example, will it be combined with another variable or will it be split apart into word combinations? The recipe provides answers to these questions.
#create_evaluation(options = {}) ⇒ Types::CreateEvaluationOutput
Creates a new Evaluation of an MLModel. An MLModel is evaluated on a set of observations associated to a DataSource. Like a DataSource for an MLModel, the DataSource for an Evaluation contains values for the Target Variable. The Evaluation compares the predicted result for each observation to the actual outcome and provides a summary so that you know how effective the MLModel functions on the test data. Evaluation generates a relevant performance metric, such as BinaryAUC, RegressionRMSE or MulticlassAvgFScore based on the corresponding MLModelType: BINARY, REGRESSION or MULTICLASS.
CreateEvaluation is an asynchronous operation. In response to CreateEvaluation, Amazon Machine Learning (Amazon ML) immediately returns and sets the evaluation status to PENDING. After the Evaluation is created and ready for use, Amazon ML sets the status to COMPLETED.
You can use the GetEvaluation operation to check progress of the evaluation during the creation operation.
#create_ml_model(options = {}) ⇒ Types::CreateMLModelOutput
Creates a new MLModel using the DataSource and the recipe as information sources.
An MLModel is nearly immutable. Users can update only the MLModelName and the ScoreThreshold in an MLModel without creating a new MLModel.
CreateMLModel is an asynchronous operation. In response to CreateMLModel, Amazon Machine Learning (Amazon ML) immediately returns and sets the MLModel status to PENDING. After the MLModel has been created and ready is for use, Amazon ML sets the status to COMPLETED.
You can use the GetMLModel operation to check the progress of the MLModel during the creation operation.
CreateMLModel requires a DataSource with computed statistics, which can be created by setting ComputeStatistics to true in CreateDataSourceFromRDS, CreateDataSourceFromS3, or CreateDataSourceFromRedshift operations.
#create_realtime_endpoint(options = {}) ⇒ Types::CreateRealtimeEndpointOutput
Creates a real-time endpoint for the MLModel. The endpoint contains the URI of the MLModel; that is, the location to send real-time prediction requests for the specified MLModel.
#delete_batch_prediction(options = {}) ⇒ Types::DeleteBatchPredictionOutput
Assigns the DELETED status to a BatchPrediction, rendering it unusable.
After using the DeleteBatchPrediction operation, you can use the GetBatchPrediction operation to verify that the status of the BatchPrediction changed to DELETED.
Caution: The result of the DeleteBatchPrediction operation is irreversible.
#delete_data_source(options = {}) ⇒ Types::DeleteDataSourceOutput
Assigns the DELETED status to a DataSource, rendering it unusable.
After using the DeleteDataSource operation, you can use the GetDataSource operation to verify that the status of the DataSource changed to DELETED.
Caution: The results of the DeleteDataSource operation are irreversible.
#delete_evaluation(options = {}) ⇒ Types::DeleteEvaluationOutput
Assigns the DELETED status to an Evaluation, rendering it unusable.
After invoking the DeleteEvaluation operation, you can use the GetEvaluation operation to verify that the status of the Evaluation changed to DELETED.
The results of the DeleteEvaluation operation are irreversible.
#delete_ml_model(options = {}) ⇒ Types::DeleteMLModelOutput
Assigns the DELETED status to an MLModel, rendering it unusable.
After using the DeleteMLModel operation, you can use the GetMLModel operation to verify that the status of the MLModel changed to DELETED.
Caution: The result of the DeleteMLModel operation is irreversible.
#delete_realtime_endpoint(options = {}) ⇒ Types::DeleteRealtimeEndpointOutput
Deletes a real time endpoint of an MLModel.
#delete_tags(options = {}) ⇒ Types::DeleteTagsOutput
Deletes the specified tags associated with an ML object. After this operation is complete, you can't recover deleted tags.
If you specify a tag that doesn't exist, Amazon ML ignores it.
#describe_batch_predictions(options = {}) ⇒ Types::DescribeBatchPredictionsOutput
Returns a list of BatchPrediction operations that match the search criteria in the request.
#describe_data_sources(options = {}) ⇒ Types::DescribeDataSourcesOutput
Returns a list of DataSource that match the search criteria in the request.
#describe_evaluations(options = {}) ⇒ Types::DescribeEvaluationsOutput
Returns a list of DescribeEvaluations that match the search criteria in the request.
#describe_ml_models(options = {}) ⇒ Types::DescribeMLModelsOutput
Returns a list of MLModel that match the search criteria in the request.
#describe_tags(options = {}) ⇒ Types::DescribeTagsOutput
Describes one or more of the tags for your Amazon ML object.
#get_batch_prediction(options = {}) ⇒ Types::GetBatchPredictionOutput
Returns a BatchPrediction that includes detailed metadata, status, and data file information for a Batch Prediction request.
#get_data_source(options = {}) ⇒ Types::GetDataSourceOutput
Returns a DataSource that includes metadata and data file information, as well as the current status of the DataSource.
GetDataSource provides results in normal or verbose format. The verbose format adds the schema description and the list of files pointed to by the DataSource to the normal format.
#get_evaluation(options = {}) ⇒ Types::GetEvaluationOutput
Returns an Evaluation that includes metadata as well as the current status of the Evaluation.
#get_ml_model(options = {}) ⇒ Types::GetMLModelOutput
Returns an MLModel that includes detailed metadata, data source information, and the current status of the MLModel.
GetMLModel provides results in normal or verbose format.
#predict(options = {}) ⇒ Types::PredictOutput
Generates a prediction for the observation using the specified ML Model.
Not all response parameters will be populated. Whether a response parameter is populated depends on the type of model requested.
#update_batch_prediction(options = {}) ⇒ Types::UpdateBatchPredictionOutput
Updates the BatchPredictionName of a BatchPrediction.
You can use the GetBatchPrediction operation to view the contents of the updated data element.
#update_data_source(options = {}) ⇒ Types::UpdateDataSourceOutput
Updates the DataSourceName of a DataSource.
You can use the GetDataSource operation to view the contents of the updated data element.
#update_evaluation(options = {}) ⇒ Types::UpdateEvaluationOutput
Updates the EvaluationName of an Evaluation.
You can use the GetEvaluation operation to view the contents of the updated data element.
#update_ml_model(options = {}) ⇒ Types::UpdateMLModelOutput
Updates the MLModelName and the ScoreThreshold of an MLModel.
You can use the GetMLModel operation to view the contents of the updated data element.
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
Basic Usage
Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)
Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:
# poll for ~25 seconds
client.wait_until(...) do |w|
w.max_attempts = 5
w.delay = 5
end
Callbacks
You can be notified before each polling attempt and before each
delay. If you throw :success or :failure from these callbacks,
it will terminate the waiter.
started_at = Time.now
client.wait_until(...) do |w|
# disable max attempts
w.max_attempts = nil
# poll for 1 hour, instead of a number of attempts
w.before_wait do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
end
Handling Errors
When a waiter is successful, it returns true. When a waiter
fails, it raises an error. All errors raised extend from
Waiters::Errors::WaiterFailed.
begin
client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:
| Waiter Name | Client Method | Default Delay: | Default Max Attempts: |
|---|---|---|---|
| :batch_prediction_available | #describe_batch_predictions | 30 | 60 |
| :data_source_available | #describe_data_sources | 30 | 60 |
| :evaluation_available | #describe_evaluations | 30 | 60 |
| :ml_model_available | #describe_ml_models | 30 | 60 |