This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] | |
app = dash.Dash(__name__, external_stylesheets=external_stylesheets) | |
app.layout = html.Div(children=[ | |
html.H1(children='Hello Dash'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
COUNTRY_COLUMN = "Country/Region" | |
LOCATION_COLUMN = "Location" | |
DATE_COLUMN = "Date" | |
TYPE_COLUMN = "Type" | |
INFECTED_COLUMN = "Infected" | |
RECOVERED_COLUMN = "Recovered" | |
DEATHS_COLUMN = "Deaths" | |
CURRENT_COLUMN = "Current" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws_region="<region>" | |
aws_profile="<profile>" | |
function_bucket_name="<bucket-for-lambda-function>" | |
function_version="<version>" | |
s3_bucket_name_1="<bucket-1>" | |
s3_bucket_name_2="<bucket-2>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
backend "s3" { | |
bucket = "<bucket-name>" | |
key = "fraud-detection/terraform.tfstate" | |
region = "<region>" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cloudwatch_event.tf | |
resource "aws_cloudwatch_event_rule" "fraud_detection_scheduled_rule" { | |
name = "fraud-detection-scheduled-rule" | |
schedule_expression = "rate(1 minute)" | |
... | |
} | |
# iam_lambda.tf | |
resource "aws_iam_role" "fraud_detection_lambda_role" { | |
name = "fraud-detection-lambda-role" | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linear_predictor = linear.deploy(initial_instance_count=1, | |
endpoint_name="fraud-detection-endpoint", | |
instance_type='ml.m4.xlarge') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# i. Download sample data and extract features and label (fraud/nonfraud). | |
... | |
# ii. Convert the n-dimensional arrays into RecordIO format (a highly efficient data format). | |
import sagemaker.amazon.common as smac | |
buf = io.BytesIO() | |
smac.write_numpy_to_dense_tensor(buf, features, labels) | |
... | |
# iii. Store the RecordIO data into S3 bucket. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /home/ec2-user/SageMaker | |
aws s3 cp s3://${function_bucket_name}-${aws_region}/fraud-detection-using-machine-learning/${function_version}/notebooks/sagemaker_fraud_detection.ipynb . | |
sed -i 's/fraud-detection-end-to-end-demo/${s3_bucket_name_1}/g' sagemaker_fraud_detection.ipynb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_sagemaker_notebook_instance" "basic" { | |
name = "FraudDetectionNotebookInstance" | |
role_arn = "${aws_iam_role.sm_notebook_instance_role.arn}" | |
instance_type = "ml.t2.medium" | |
lifecycle_config_name = "${aws_sagemaker_notebook_instance_lifecycle_configuration.basic_lifecycle.name}" | |
} | |
resource "aws_sagemaker_notebook_instance_lifecycle_configuration" "basic_lifecycle" { | |
name = "BasicNotebookInstanceLifecycleConfig" | |
on_start = "${base64encode(data.template_file.instance_init.rendered)}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iam_sagemaker.tf | |
resource "aws_iam_role" "sm_notebook_instance_role" { | |
name = "sm-notebook-instance-role" | |
... | |
} | |
resource "aws_iam_policy" "sm_notebook_instance_policy" { | |
name = "sm-notebook-instance-policy" | |
description = "Policy for the Notebook Instance to manage training jobs, models and endpoints" | |
... | |
} |