Why does my prediction always show high risk?
Show older comments
Hello everyone.
I want to ask a question regarding my final year project.
I'm currently doing a prediction system using:
- UCI heart disease dataset.
- Ensemble method (Subspace Discriminant) trained model from Classifier Learner App.
- a GUI from app designer.
The system shown no problem when detecting a high parameter for high risk patient data and correctly shows 'Heart Disease Detected' but for a low parameter for a normal patient data it still shows the output as 'Heart Disease Detected'. It is because of the dataset's value comes from patients that already suspect with heart disease or the model used is sensitive. The GUI screenshot is suppose to be a normal patient data.
If you have an insight about this please share with me. Thank you.
I'll share the coding used in the app designer and the GUI with some of the patient attribute data where the target is suppose to be the outcome of this system prediction.
properties (Access = private)
modelData = load('HeartModel.mat','trainedModel');
end
methods (Access = private)
function startupFcn(app)
% Set DropDown items and ItemsData for numerical values
% Sex
app.SexDropDown.Items = {'Female', 'Male'};
app.SexDropDown.ItemsData = [0, 1];
% Chest Pain (cp)
app.ChestPainDropDown.Items = {'Normal','Typical Angina', 'Atypical Angina', 'Non-anginal Pain', 'Asymptomatic'};
app.ChestPainDropDown.ItemsData = [0, 1, 2, 3, 4];
% Fasting Blood Sugar (fbs)
app.FastingBloodSugarDropDown.Items = {'<= 120 mg/dL', '> 120 mg/dL'};
app.FastingBloodSugarDropDown.ItemsData = [0, 1];
% Rest ECG (restecg)
app.RestECGDropDown.Items = {'Normal', 'ST-T Wave Abnormality', 'LV Hypertrophy'};
app.RestECGDropDown.ItemsData = [0, 1, 2];
% Slope
app.SlopeDropDown.Items = {'Upsloping', 'Flat', 'Downsloping'};
app.SlopeDropDown.ItemsData = [1, 2, 3];
% Exercise Angina (exang)
app.ExerciseAnginaDropDown.Items = {'No', 'Yes'};
app.ExerciseAnginaDropDown.ItemsData = [0, 1];
% CA
app.CADropDown.Items = {'0', '1', '2', '3'};
app.CADropDown.ItemsData = [0, 1, 2, 3];
% Thal
app.ThalDropDown.Items = {'Normal', 'Fixed Defect', 'Reversible Defect'};
app.ThalDropDown.ItemsData = [3, 6, 7];
end
end
% Button pushed function: PredictButton
function PredictButtonPushed(app, event)
% Collect all inputs (convert to double to be safe)
age = double(app.AgeEditField.Value);
sex = double(app.SexDropDown.Value);
cp = double(app.ChestPainDropDown.Value);
trestbps = double(app.RestingBPEditField.Value);
chol = double(app.CholesterolEditField.Value);
fbs = double(app.FastingBloodSugarDropDown.Value);
restecg = double(app.RestECGDropDown.Value);
thalach = double(app.MaxHeartRateEditField.Value);
exang = double(app.ExerciseAnginaDropDown.Value);
oldpeak = double(app.OldpeakEditField.Value);
slope = double(app.SlopeDropDown.Value);
ca = double(app.CADropDown.Value);
thal = double(app.ThalDropDown.Value);
% Create input table
T = table(age, sex, cp, trestbps, chol, fbs, restecg, thalach, ...
exang, oldpeak, slope, ca, thal, ...
'VariableNames', {'age','sex','cp','trestbps','chol','fbs',...
'restecg','thalach','exang','oldpeak',...
'slope','ca','thal'});
%Prediction
label = app.modelData.trainedModel.predictFcn(T);
% Display result
if label == 0
app.ResultLabel.Text = 'No Heart Disease';
app.ResultLabel.FontColor = [0 1 0]; % Green
else
app.ResultLabel.Text = 'Heart Disease Detected';
app.ResultLabel.FontColor = [1 0 0]; % Red
end


3 Comments
Everything is tied up in one line
label = app.modelData.trainedModel.predictFcn(T);
You will have to have sufficient normal data as well as unhealthy conditions in the dataset in order to be able to effectively train and then discrimante between the two cases.
We have no way to be able to say anything definitive from just the general description -- one first thing might be to try discriminant analyses and do coditional plots of the measured parameters to see which are those that actually do correlate with the condition to be detected.
Halimatun Saadiah
on 2 Jan 2026
The other comment indicates that the model itself apparently isn't the problem, presuming the conclusion drawn there is correct that the model does predict good/bad as expected.
The above would only be of real use if, as was implied initially, that the model itself is always returning one value -- as noted, that other comment indicates the problem is in either the GUI isn't calling the model with the correct inputs/getting the expected results or in the conversion of the correct output to the displayed value if the model itself is being called correctly.
This could be something wrong in a logical expression that is miscoded such that it will always return true or false regardless of the input.
If the model returns a value in the range 0-1, for example, then checking for nonzero alone wouldn't work as expected because even a likelihood value of 1% chance of disease would still test as True.
Accepted Answer
More Answers (0)
Categories
Find more on Biological and Health Sciences in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!