himanshu208

Untitled

Oct 7th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. import boto3
  2.  
  3. client = boto3.client('machinelearning')
  4. print "connected to ml"
  5. try:
  6. #datasource for testing
  7.  
  8. response = client.create_data_source_from_s3(
  9. DataSourceId='test-1234-id-11a',
  10. DataSourceName='test-1234-test',
  11. DataSpec={
  12. 'DataLocationS3': 's3://1234-ml/banking.csv',
  13. 'DataRearrangement':"{\"splitting\":{\"percentBegin\":90,\"percentEnd\":100}}",
  14. 'DataSchemaLocationS3': 's3://1234-ml/dataschema.json'
  15. },
  16. ComputeStatistics=True
  17. )
  18. print "data for testing created"
  19. #training data source
  20. response = client.create_data_source_from_s3(
  21. DataSourceId='train-1234-id-12a',
  22. DataSourceName='test-1234-data',
  23. DataSpec={
  24. 'DataLocationS3': 's3://1234-ml/banking.csv',
  25. 'DataRearrangement':"{\"splitting\":{\"percentBegin\":0,\"percentEnd\":90}}",
  26. 'DataSchemaLocationS3': 's3://1234-ml/dataschema.json'
  27. },
  28. ComputeStatistics=True
  29. )
  30. print "data for training created"
  31. response = client.create_ml_model(
  32. MLModelId='ml-1234-model-1a',
  33. MLModelName='ml-1234-model-name',
  34. MLModelType='BINARY',
  35. TrainingDataSourceId='train-1234-id-12a'
  36. )
  37. print "model created "
  38. response = client.create_evaluation(
  39. EvaluationId='ml-1234-eval-1a',
  40. EvaluationName='ml-1234-eval-name',
  41. MLModelId='ml-1234-model-1a',
  42. EvaluationDataSourceId='test-1234-id-11a'
  43. )
  44. print "model evaluation "
  45. response = client.get_evaluation(
  46. EvaluationId='ml-1234-eval-1a'
  47. )
  48. print "getting evaluation "
  49. print response
  50. except Exception as e:
  51. print(e)
Add Comment
Please, Sign In to add comment