WE have trained a dataset for credit fraud detection and we want to predict single record whether it belongs to class 1 or 0
FYI: 1 means fraud and 0 means normal
The below code is inspired from the below link
This file has been truncated.
"It's Sunday morning, it's quiet and you wake up with a big smile on your face. Today is going to be a great day! Except, your phone rings, rather \"internationally\". You pick it up slowly and hear something really bizarre - \"Bonjour, je suis Michele. Oops, sorry. I am Michele, your personal bank agent.\". What could possibly be so urgent for someone from Switzerland to call you at this hour? \"Did you authorize a transaction for $3,358.65 for 100 copies of Diablo 3?\" Immediately, you start thinking of ways to explain why you did that to your loved one. \"No, I didn't !?\". Michele's answer is quick and to the point - \"Thank you, we're on it\". Whew, that was close! But how did Michele knew that this transaction was suspicious? After all, you did order 10 new smartphones from that same bank account, last week - Michele didn't call then.\n",
"Annual global fraud losses reached $21.8 billion in 2015, according to [Nilson Report](https://www.nilsonreport.com/upload/content_promo/The_Nilson_Report_10-17-2016.pdf). \n",
"Probably you feel very lucky if you are a fraud. About every 12 cents per $100 were stolen in the US during the same year. Our friend Michele might have a serious problem to solve here.\n",
"In this part of the series, we will train an Autoencoder Neural Network (implemented in Keras) in unsupervised (or semi-supervised) fashion for Anomaly Detection in credit card transaction data. The trained model will be evaluated on pre-labeled and anonymized dataset.\n",
"We will be using TensorFlow 1.2 and Keras 2.0.4. Let's begin:"
autoencoder = load_model(‘model.h5’)
predictions = autoencoder.predict(b,verbose=0)
From the output “predictions” we r not able to get the class. pls suggest
It looks like you are using Keras or did you implement the same model in PyTorch?
If so, could you post the model architecture or the shape of your last linear layer?
I assume you’ve used a single output with
nn.BCELoss/nn.BCEWithLogitsLoss or two output units with
In the first case, you can just apply a threshold (e.g. 0.5) or fine tune it using the ROC, which you would apply
torch.argmax(output, 1) in the latter case to get the prediction.