Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import boto3
- client = boto3.client('machinelearning')
- print "connected to ml"
- try:
- #datasource for testing
- response = client.create_data_source_from_s3(
- DataSourceId='test-1234-id-11a',
- DataSourceName='test-1234-test',
- DataSpec={
- 'DataLocationS3': 's3://1234-ml/banking.csv',
- 'DataRearrangement':"{\"splitting\":{\"percentBegin\":90,\"percentEnd\":100}}",
- 'DataSchemaLocationS3': 's3://1234-ml/dataschema.json'
- },
- ComputeStatistics=True
- )
- print "data for testing created"
- #training data source
- response = client.create_data_source_from_s3(
- DataSourceId='train-1234-id-12a',
- DataSourceName='test-1234-data',
- DataSpec={
- 'DataLocationS3': 's3://1234-ml/banking.csv',
- 'DataRearrangement':"{\"splitting\":{\"percentBegin\":0,\"percentEnd\":90}}",
- 'DataSchemaLocationS3': 's3://1234-ml/dataschema.json'
- },
- ComputeStatistics=True
- )
- print "data for training created"
- response = client.create_ml_model(
- MLModelId='ml-1234-model-1a',
- MLModelName='ml-1234-model-name',
- MLModelType='BINARY',
- TrainingDataSourceId='train-1234-id-12a'
- )
- print "model created "
- response = client.create_evaluation(
- EvaluationId='ml-1234-eval-1a',
- EvaluationName='ml-1234-eval-name',
- MLModelId='ml-1234-model-1a',
- EvaluationDataSourceId='test-1234-id-11a'
- )
- print "model evaluation "
- response = client.get_evaluation(
- EvaluationId='ml-1234-eval-1a'
- )
- print "getting evaluation "
- print response
- except Exception as e:
- print(e)
Add Comment
Please, Sign In to add comment