Why does my prediction always show high risk?
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
endHello 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 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 app designer, appdesigner MATLAB Answers — New Questions









