I've been trying the kaggle dataset of Credit card fraud detection Dataset . I've used ANN using keras and tensorflow. You can find the code in the screenshot. The only problem is im getting accuracy to be around 99.9 % , so i think it's surely a case of some false hopes or over fitting. Can you please tell whats wrong with it? And even my test set gave a result of 99.93% accuracy.

enter image description here

  • 3
    $\begingroup$ Hi, welcome to Data Science StackExchange! Please avoid posting code as image: it is not easily read, cannot be copy-pasted, and generates unnecessary hosting. $\endgroup$ Nov 19, 2019 at 5:43
  • $\begingroup$ Please provide train and test loss graphs, there we can check for problems, and accuracy 99.9 %, is it train accuracy or validation accuracy? $\endgroup$
    – Elbek
    Nov 19, 2019 at 6:25
  • $\begingroup$ hey , sorry i didnt knwo about that. @Elbek the training set as well as test set accuracy is 99.9 % .And is it possible to show graphs even for independent 30 independent variables? $\endgroup$
    – Gaurav Roy
    Nov 19, 2019 at 6:35
  • $\begingroup$ @GauravRoy just show graph of loss $\endgroup$
    – Elbek
    Nov 19, 2019 at 8:19
  • $\begingroup$ any link how to do that? $\endgroup$
    – Gaurav Roy
    Nov 19, 2019 at 8:43

1 Answer 1


This dataset presents transactions that occurred in two days, where we have 492 frauds out of 284,807 transactions. The dataset is highly unbalanced, the positive class (frauds) account for 0.172% of all transactions.

I guess your model learnt nothing at all ;)

You should consider some form of resampling and using metrics that can handle imbalance. This might be a good starting point. You can find bunch of similar threads here as well.

  • $\begingroup$ okay , so why didnt my model learn anything? didnt get that part? i should have a balanced dataset for that? and how to tackle it? $\endgroup$
    – Gaurav Roy
    Nov 19, 2019 at 8:45
  • 2
    $\begingroup$ Your model overfits to over-represented class. You can just output not-fraud all the time and you'll get 83% accuracy. Accuracy is counted globally and doesn't account for imbalance. Check this kernel and this one. Before you jump into DNN you should first explore more classical models like random forest or xgboost, they're much faster to fit. This data set is rather tough and you won't get away with just simple rescaler. $\endgroup$ Nov 19, 2019 at 8:57
  • $\begingroup$ oh okay, great. thanks. got to know something new. will ask if any doubgs $\endgroup$
    – Gaurav Roy
    Nov 19, 2019 at 9:08
  • 1
    $\begingroup$ Ups, got my math wrong. Constant not-fraud model would give you 99.3% accuracy. $\endgroup$ Nov 19, 2019 at 9:10
  • 1
    $\begingroup$ Do projects. People learn by experience. Watching tutorials will get you nowhere. When it comes to DNN it's nice to have someone holding your hand and start from basics. This is great book. Cannot recommend it more. $\endgroup$ Nov 19, 2019 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.