In [1]:
import boto3

In [2]:
ml_model_id = 'ml-HzDofty2GmI'
end_point = 'https://realtime.machinelearning.us-east-1.amazonaws.com'

In [3]:
session = boto3.Session(
    region_name = 'us-east-1',
    profile_name = 'ml_user_predict')

In [4]:
ml = session.client('machinelearning')

In [5]:
iris_record = \
    {"Row":"1",
     "sepal_length":"5.4",
     "sepal_width":"3.0",
     "petal_length":"4.5",
     "petal_width":"1.5"}

In [6]:
iris_record


Out[6]:
{'Row': '1',
 'petal_length': '4.5',
 'petal_width': '1.5',
 'sepal_length': '5.4',
 'sepal_width': '3.0'}

In [7]:
iris_prediction = ml.predict(MLModelId = ml_model_id, 
                             Record = iris_record, 
                             PredictEndpoint = end_point)

In [8]:
iris_prediction['Prediction']


Out[8]:
{'details': {'Algorithm': 'SGD', 'PredictiveModelType': 'MULTICLASS'},
 'predictedLabel': 'Iris-versicolor',
 'predictedScores': {'Iris-setosa': 0.007112426683306694,
  'Iris-versicolor': 0.9897872805595398,
  'Iris-virginica': 0.0031002822797745466}}

In [9]:
iris_prediction['Prediction']['predictedLabel']


Out[9]:
'Iris-versicolor'

In [10]:
iris_prediction


Out[10]:
{'Prediction': {'details': {'Algorithm': 'SGD',
   'PredictiveModelType': 'MULTICLASS'},
  'predictedLabel': 'Iris-versicolor',
  'predictedScores': {'Iris-setosa': 0.007112426683306694,
   'Iris-versicolor': 0.9897872805595398,
   'Iris-virginica': 0.0031002822797745466}},
 'ResponseMetadata': {'HTTPHeaders': {'content-length': '247',
   'content-type': 'application/x-amz-json-1.1',
   'date': 'Wed, 27 Sep 2017 01:22:27 GMT',
   'x-amzn-requestid': '532c7fa2-a322-11e7-a3e5-8f6a7322b427'},
  'HTTPStatusCode': 200,
  'RequestId': '532c7fa2-a322-11e7-a3e5-8f6a7322b427',
  'RetryAttempts': 0}}