Amazon ML examples using Tools for PowerShell V5 - Amazon Tools for PowerShell (version 5)
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Version 5 (V5) of the Amazon Tools for PowerShell has been released!

For information about breaking changes and migrating your applications, see the migration topic.

Amazon ML examples using Tools for PowerShell V5

The following code examples show you how to perform actions and implement common scenarios by using the Amazon Tools for PowerShell V5 with Amazon ML.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use Get-MLBatchPrediction.

Tools for PowerShell V5

Example 1: Returns the detailed metadata for a batch prediction with id ID.

Get-MLBatchPrediction -BatchPredictionId ID
  • For API details, see GetBatchPrediction in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-MLBatchPredictionList.

Tools for PowerShell V5

Example 1: Returns a list of all BatchPredictions and their associated data records that match the search criterion given in the request.

Get-MLBatchPredictionList

Example 2: Returns a list of all BatchPredictions with a status of COMPLETED.

Get-MLBatchPredictionList -FilterVariable Status -EQ COMPLETED

The following code example shows how to use Get-MLDataSource.

Tools for PowerShell V5

Example 1: Returns the metadata, status, and data file information for a DataSource with the id ID

Get-MLDataSource -DataSourceId ID
  • For API details, see GetDataSource in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-MLDataSourceList.

Tools for PowerShell V5

Example 1: Returns a list of all DataSources and their associated data records.

Get-MLDataSourceList

Example 2: Returns a list of all DataSources with a status of COMPLETED.

Get-MLDataDourceList -FilterVariable Status -EQ COMPLETED
  • For API details, see DescribeDataSources in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-MLEvaluation.

Tools for PowerShell V5

Example 1: Returns metadata and status for an Evaluation with id ID.

Get-MLEvaluation -EvaluationId ID
  • For API details, see GetEvaluation in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-MLEvaluationList.

Tools for PowerShell V5

Example 1: Returns a list of all Evaluation resources

Get-MLEvaluationList

Example 2: Returns a list of all Evaulations with a status of COMPLETED.

Get-MLEvaluationList -FilterVariable Status -EQ COMPLETED
  • For API details, see DescribeEvaluations in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-MLModel.

Tools for PowerShell V5

Example 1: Returns the detail metadata, status, schema, and data file information for a MLModel with id ID.

Get-MLModel -ModelId ID
  • For API details, see GetMLModel in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-MLModelList.

Tools for PowerShell V5

Example 1: Returns a list of all Models and their associated data records.

Get-MLModelList

Example 2: Returns a list of all Models with a status of COMPLETED.

Get-MLModelList -FilterVariable Status -EQ COMPLETED
  • For API details, see DescribeMLModels in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-MLPrediction.

Tools for PowerShell V5

Example 1: Send a record to the realtime prediction endpoint URL for Model with id ID.

Get-MLPrediction -ModelId ID -PredictEndpoint URL -Record @{"A" = "B"; "C" = "D";}
  • For API details, see Predict in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use New-MLBatchPrediction.

Tools for PowerShell V5

Example 1: Create a new batch prediction request for model with id ID and put the output at the specified S3 location.

New-MLBatchPrediction -ModelId ID -Name NAME -OutputURI s3://...

The following code example shows how to use New-MLDataSourceFromS3.

Tools for PowerShell V5

Example 1: Create a data source with data for an S3 location, with a name of NAME and a schema of SCHEMA.

New-MLDataSourceFromS3 -Name NAME -ComputeStatistics $true -DataSpec_DataLocationS3 "s3://BUCKET/KEY" -DataSchema SCHEMA

The following code example shows how to use New-MLEvaluation.

Tools for PowerShell V5

Example 1: Create an evaluation for a given data source id and model id

New-MLEvaluation -Name NAME -DataSourceId DSID -ModelId MID
  • For API details, see CreateEvaluation in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use New-MLModel.

Tools for PowerShell V5

Example 1: Create a new model with training data.

New-MLModel -Name NAME -ModelType BINARY -Parameter @{...} -TrainingDataSourceId ID
  • For API details, see CreateMLModel in Amazon Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use New-MLRealtimeEndpoint.

Tools for PowerShell V5

Example 1: Create a new realtime prediction endpoint for the given model id.

New-MLRealtimeEndpoint -ModelId ID