Icon

02_​Fraud_​Detection_​Deployment_​Solution

Keras Autoencoder for Fraud Detection - Deployment

Exercise of the L4-DL Introduction to Deep Learning Course.

The goal of this exercise is to apply a trained autoencoder to new transactions, in order to detect the fraudulent ones.

URL: L4-DL course slides https://www.knime.com/form/material-download-registration

Step 2. The Fraud DetectorNormalize the deployment data with the Normalizer (Apply) nodeApply the normalized data to the autoencoder by the Keras Network Executor nodeMSE calculation with the MSE Calculation component, found in components folderThe input is the output from the Keras Network Executor node.Classify transactions based on their MSE and the threshold K, using the Rule Engine nodeUse the output from the MSE Calculation componentThreshold K is read as a flow variable “Threshold” from Table Row to Variable nodeIf the MSE (reconstruction_error) is lower than the flow variable Threshold, then the sample is classifiednormal (“0”), otherwise classified as fraudulent (“1”).Append the classification results as a new column “prediction” Step 1. Reading data, parameters, and networkThe deployment data set, the normalization model, the Kerasnetwork model for the autoencoder, and the threshold forfraudulent observations are read from the data folder. Session 2 - Introduction to Deep LearningExercise 02 Keras Autoencoder for Fraud Detection - Deployment Learning objective: In this exercise, you'll learn how to apply a trained autoencoder to new transactions, in order to detect the fraudulent ones.Workflow description: The deployment dataset contains 2 samples with 30 numeric features derived from credit card transactions. An autoencoder trained for fraud detection is deployed to this data set. If a transaction is discovered as fraudulent, an email alert will be sent.You'll find the instructions to the exercises in the yellow annotations. Step 3. Taking ActionsConvert the prediction to a flow variable with the Table Row to Variable nodeUsing the CASE Switch (Start) node to determine the actionAdd flow variable portsActive port is controlled by the flow variable “prediction”If prediction=0 (i.e., legitimate), then do nothingIf prediction=1 (i.e., fraudulent), then send an email alert with the Send Email node Read Keras modelcreditcard_autoencoder.h5 Reconstructdeployment datawith autoencoderDefine outliers bythe best threshold forreconstruction errorsend email to ownerNormalizationmodelnormalizer.modelNode 134Read threshold.tableDeployment datacreditcard_deployment.csvport 0 => trx legitport 1 => fraud?Keras NetworkReader Normalizer (Apply) Keras NetworkExecutor Rule Engine Send Email Model Reader Table RowTo Variable Table RowTo Variable MSE Calculation Table Reader CSV Reader CASE Switch Start Step 2. The Fraud DetectorNormalize the deployment data with the Normalizer (Apply) nodeApply the normalized data to the autoencoder by the Keras Network Executor nodeMSE calculation with the MSE Calculation component, found in components folderThe input is the output from the Keras Network Executor node.Classify transactions based on their MSE and the threshold K, using the Rule Engine nodeUse the output from the MSE Calculation componentThreshold K is read as a flow variable “Threshold” from Table Row to Variable nodeIf the MSE (reconstruction_error) is lower than the flow variable Threshold, then the sample is classifiednormal (“0”), otherwise classified as fraudulent (“1”).Append the classification results as a new column “prediction” Step 1. Reading data, parameters, and networkThe deployment data set, the normalization model, the Kerasnetwork model for the autoencoder, and the threshold forfraudulent observations are read from the data folder. Session 2 - Introduction to Deep LearningExercise 02 Keras Autoencoder for Fraud Detection - Deployment Learning objective: In this exercise, you'll learn how to apply a trained autoencoder to new transactions, in order to detect the fraudulent ones.Workflow description: The deployment dataset contains 2 samples with 30 numeric features derived from credit card transactions. An autoencoder trained for fraud detection is deployed to this data set. If a transaction is discovered as fraudulent, an email alert will be sent.You'll find the instructions to the exercises in the yellow annotations. Step 3. Taking ActionsConvert the prediction to a flow variable with the Table Row to Variable nodeUsing the CASE Switch (Start) node to determine the actionAdd flow variable portsActive port is controlled by the flow variable “prediction”If prediction=0 (i.e., legitimate), then do nothingIf prediction=1 (i.e., fraudulent), then send an email alert with the Send Email node Read Keras modelcreditcard_autoencoder.h5Reconstructdeployment datawith autoencoderDefine outliers bythe best threshold forreconstruction errorsend email to ownerNormalizationmodelnormalizer.modelNode 134Read threshold.tableDeployment datacreditcard_deployment.csvport 0 => trx legitport 1 => fraud?Keras NetworkReader Normalizer (Apply) Keras NetworkExecutor Rule Engine Send Email Model Reader Table RowTo Variable Table RowTo Variable MSE Calculation Table Reader CSV Reader CASE Switch Start

Nodes

Extensions

Links