{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# An Introduction to the Amazon Fraud Detector API \n", "#### Supervised fraud detection \n", "-------\n", "\n", "## Introduction\n", "-------\n", "\n", "Amazon Fraud Detector is a fully managed service that makes it easy to identify potentially fraudulent online activities such as online payment fraud and the creation of fake accounts. Fraud Detector capitalizes on the latest advances in machine learning (ML) and 20 years of fraud detection expertise from AWS and Amazon.com to automatically identify potentially fraudulent activity so you can catch more fraud faster.\n", "\n", "If you would like to know more, please check out [Fraud Detector's Documentation](https://docs.aws.amazon.com/frauddetector/). " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.core.display import display, HTML\n", "from IPython.display import clear_output\n", "display(HTML(\"\"))\n", "# ------------------------------------------------------------------\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "pd.set_option('display.max_rows', 500)\n", "pd.set_option('display.max_columns', 500)\n", "pd.set_option('display.width', 1000)\n", "\n", "import os\n", "import sys\n", "import time\n", "import json\n", "import uuid \n", "from datetime import datetime\n", "\n", "# -- AWS stuff -- \n", "import boto3\n", "import sagemaker\n", "from sagemaker import get_execution_role\n", "\n", "# -- sklearn --\n", "from sklearn.metrics import roc_curve, roc_auc_score, auc, roc_auc_score\n", "%matplotlib inline " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# -- initialize the AFD client \n", "client = boto3.client('frauddetector')\n", "\n", "# -- suffix is appended to detector and model name for uniqueness \n", "sufx = datetime.now().strftime(\"%Y%m%d\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Setup \n", "-----\n", "\n", "***To get started *** \n", "\n", "1. Load the config.json that was created for you\n", "2. The properties EVENT_TYPE, ENTITY_TYPE, MODEL_NAME and DETECTOR_NAME will all be set for you based on your configuration. The names you named in your CloudFormation template will be set here.\n", "3. Load ARN of you local instance\n", "4. Let the source file from S3 be specified\n", "\n", "Then you can interactively exeucte the code cells in the notebook, no need to change anything unless you want to. \n", "\n", "\n", "