Skip to content
Advertisement

Python Keras ValueError: Data cardinality is ambiguous

I am attempting to make a model that can predict whether a credit card transaction was fraudulent or not. My dataset is available on Kaggle. Everything works up to when I fit my model, when I get this error:

JavaScript

Could someone help me figure out what’s wrong?

JavaScript

Advertisement

Answer

The main issue with your code is that the model’s input shape should be 30 and not 1 as you have 30 features, while the output shape should be 1 and not 2 since you have only one binary label (i.e. only two classes, 0 or 1). There were also a few other bugs which were corrected in the code below.

JavaScript
Advertisement