Skip to content

Instantly share code, notes, and snippets.

@harishkashyap
Created January 28, 2023 07:10
Show Gist options
  • Save harishkashyap/c1dc3f5194a0f15586dec6138b52012b to your computer and use it in GitHub Desktop.
Save harishkashyap/c1dc3f5194a0f15586dec6138b52012b to your computer and use it in GitHub Desktop.

Revisions

  1. harishkashyap created this gist Jan 28, 2023.
    29 changes: 29 additions & 0 deletions pandita-risk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    import boto3
    import datetime
    import time
    import tarfile
    import boto3
    import pandas as pd
    import sagemaker
    from sagemaker import sklearn, get_execution_role

    sm_boto3 = boto3.client("sagemaker")
    sess = sagemaker.Session()
    region = sess.boto_session.region_name
    bucket = sess.default_bucket()

    quality_map = {0: 0.9636, 1: 0.9589, 2: 0.9775}
    cost_map = {0: 0.03049, 1: 0.015, 2: 0.01339}
    print("validating model")
    risk_type = 'RISK_VAL'
    X = ['france-uber', cost_map, quality_map, [60, 30], risk_type]

    # Instantiate a predictor object
    predictor = sklearn.model.SKLearnPredictor(
    endpoint_name="sagemaker-scikit-learn-2023-01-28-05-31-02-930",
    sagemaker_session=sess)

    # Invoke the endpoint
    predictions = predictor.predict(X)

    print(predictions)