After training my Neural network with a binary predictor, the prediction turns out to be a continuous target. How do i fix it?
It might help to know more context about what you are doing, but if you have a NN that does binary classification that probably means your output layer has sigmoid as the activation function. That means the prediction values produced by executing your model in “inference” mode are numbers between 0 and 1 that we interpret as the probability that a given input sample is classified as “True” or “Yes it’s a cat” or whatever your labels are. So if you want to convert the prediction values to “Yes” or “No” answers, the usual way to that is:
trueFalsePred = (pred > 0.5)
But I’m sure there’s a significant probability that I’m just missing the point of your question, so please give us more context if that’s the case.
cardiovascular-disease-prediction-neuralnetwork.ipynb (140.9 KB)
I am predicting whether patient have 10 year risk of coronary heart disease CHD or not, I have attached the Notebook
Anytime you are trying to solve a problem by programming, it’s essential to have a clear definition of what the goal is. So is what you are saying that instead of a binary classifier with a “yes/no” answer, you are trying to generate a number which somehow reflects the level of risk that the patient will have CHD in the next 10 years. So what does that number look like? Is it a probability? Or a number on a “risk scale” of 0 to 5 or 0 to 10? The technical way to say that is instead of a “classification” problem, you have a “regression” problem.
What is the training data that you have to work from?
Before it makes sense to even look at the code, we need a definition of the problem you are trying to solve.
The target is a binary classifier with “yes/no”, but represented as “0/1” on the dataset. Below is the data
train.csv (222.2 KB)
If the prediction is > 0.5, then it is the “True” or “Yes” class (logical ‘1’).
You’re using 500 epochs, but did you notice that the results (training accuracy) don’t get any better after the 3rd epoch?