Plotting the decision boundary for logistic regression
9 次查看(过去 30 天)
显示 更早的评论
Hi, I am trying to run a logistic regression binary classification to predict the probability of the tumour being malignant or benign. I am new to this so sorry if they solution seems obvious, I just can't seem to figure out what is wrong. I've been following Andrew Ng's tutorials on Youtube to learn the mathematical concept and how to run the code in Matlab. The dataset I am using is simulated however it is based on the UCI Wisconsin breat cancer dataset. I have a problem when plotting the decision boundary, the decision boundary is reversed and I'm not sure why. I am only using 2 features to predict the probability of the tumour. I have attached the code and dataset.
Any help is appreciated. Thank you in advance!
1 个评论
KA
2023-12-11
Hello Vivian,
I'm also working on the same data and I'm facing a few problems. If you have figured things out, could you kindly share the code with me? Thank you
回答(1 个)
Vineet Joshi
2021-3-23
You can refer the following code to check your decision boundary for Logistic regression.
%Laod & Split Data
Data = load('Test.txt');
X = Data(:,1:2);
Y = categorical(Data(:,3));
%Fit Model
B = mnrfit(X,Y);
%Plot Decision Boundry
plot(X(:,1),-((B(1)*1 + B(2) * X(:,1))/B(3)));
The output will look as follows.
Since your training accuracy is also coming close to 63%, it is less likely the plotting of the boundary is an issue. You can try improving your current model or test some other models like SVM.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!