We are no longer updating the Amazon Machine Learning service or accepting new users for it. This documentation is available for existing users, but we are no longer updating it. For more information, see What is Amazon Machine Learning.
Data Rearrangement
The data rearrangement functionality enables you to create a datasource that is based on only a portion of the input data that it points to. For example, when you create an ML Model using the Create ML Model wizard in the Amazon ML console, and choose the default evaluation option, Amazon ML automatically reserves 30% of your data for ML model evaluation, and uses the other 70% for training. This functionality is enabled by the Data Rearrangement feature of Amazon ML.
If you are using the Amazon ML API to create datasources, you can
specify which part of the input data a new datasource will be
based. You do this by passing instructions in the
DataRearrangement parameter to the CreateDataSourceFromS3,
CreateDataSourceFromRedshift or CreateDataSourceFromRDS APIs.
The contents of the DataRearrangement string are a JSON string containing the
beginning and end locations of your data, expressed as
percentages, a complement flag, and a splitting strategy. For example, the following DataRearrangement string
specifies that the first 70% of the data will be used to create
the datasource:
{ "splitting": { "percentBegin": 0, "percentEnd": 70, "complement": false, "strategy": "sequential" } }
DataRearrangement Parameters
To change how Amazon ML creates a datasource, use the follow parameters.
- PercentBegin (Optional)
-
Use
percentBeginto indicate where the data for the datasource starts. If you do not includepercentBeginandpercentEnd, Amazon ML includes all of the data when creating the datasource.Valid values are
0to100, inclusive. - PercentEnd (Optional)
-
Use
percentEndto indicate where the data for the datasource ends. If you do not includepercentBeginandpercentEnd, Amazon ML includes all of the data when creating the datasource.Valid values are
0to100, inclusive. - Complement (Optional)
-
The
complementparameter tells Amazon ML to use the data that is not included in the range ofpercentBegintopercentEndto create a datasource. Thecomplementparameter is useful if you need to create complementary datasources for training and evaluation. To create a complementary datasource, use the same values forpercentBeginandpercentEnd, along with thecomplementparameter.For example, the following two datasources do not share any data, and can be used to train and evaluate a model. The first datasource has 25 percent of the data, and the second one has 75 percent of the data.
Datasource for evaluation:
{ "splitting":{ "percentBegin":0, "percentEnd":25 } }Datasource for training:
{ "splitting":{ "percentBegin":0, "percentEnd":25, "complement":"true" } }Valid values are
trueandfalse. - Strategy (Optional)
-
To change how Amazon ML splits the data for a datasource, use the
strategyparameter.The default value for the
strategyparameter issequential, meaning that Amazon ML takes all of the data records between thepercentBeginandpercentEndparameters for the datasource, in the order that the records appear in the input dataThe following two
DataRearrangementlines are examples of sequentially ordered training and evaluation datasources:Datasource for evaluation:
{"splitting":{"percentBegin":70, "percentEnd":100, "strategy":"sequential"}}Datasource for training:
{"splitting":{"percentBegin":70, "percentEnd":100, "strategy":"sequential", "complement":"true"}}To create a datasource from a random selection of the data, set the
strategyparameter torandomand provide a string that is used as the seed value for the random data splitting (for example, you can use the S3 path to your data as the random seed string). If you choose the random split strategy, Amazon ML assigns each row of data a pseudo-random number, and then selects the rows that have an assigned number betweenpercentBeginandpercentEnd. Pseudo-random numbers are assigned using the byte offset as a seed, so changing the data results in a different split. Any existing ordering is preserved. The random splitting strategy ensures that variables in the training and evaluation data are distributed similarly. It is useful in the cases where the input data may have an implicit sort order, which would otherwise result in training and evaluation datasources containing non-similar data records.The following two
DataRearrangementlines are examples of non-sequentially ordered training and evaluation datasources:Datasource for evaluation:
{ "splitting":{ "percentBegin":70, "percentEnd":100, "strategy":"random", "strategyParams": { "randomSeed":"RANDOMSEED" } } }Datasource for training:
{ "splitting":{ "percentBegin":70, "percentEnd":100, "strategy":"random", "strategyParams": { "randomSeed":"RANDOMSEED" } "complement":"true" } }Valid values are
sequentialandrandom. - (Optional) Strategy:RandomSeed
-
Amazon ML uses the randomSeed to split the data. The default seed for the API is an empty string. To specify a seed for the random split strategy, pass in a string. For more information about random seeds, see Randomly Splitting Your Data in the Amazon Machine Learning Developer Guide.
For sample code that demonstrates how to use cross-validation with Amazon ML, go to Github Machine Learning Samples