About the scatter plot.
Show older comments
I am supposed to make a scatter from two vectors with different dimensions. I am new in neural training. I got the following code, but when I apply it in my csv file. I don't get any data scattering. But, the code works with the authors atttached file. Could anyone please suggest me a solution for my data. I am attaching my csv file.
clear all;clc;
a=csvread('hrvct.csv');
a=[a(:,1:end-1),a(:,end)];
% Divide Data in training and testing sets
[atr,ate] = holdout( a,53);
Xte=ate(:,1:end-1);Yte=ate(:,end);
Xtr=atr(:,1:end-1);Ytr=atr(:,end);
fm_=[];
% Scatter Plot of data
figure
hold on
X=[Xtr;Xte];Y=[Ytr;Yte];
scatter(X(Y==1,1),X(Y==1,2),'*g')
scatter(X(Y==-1,1),X(Y==-1,2),'*r')
hold off
5 Comments
Walter Roberson
on 25 Nov 2020
Could you link to the documentation for the holdout() function you are using?
Walter Roberson
on 25 Nov 2020
a=[a(:,1:end-1),a(:,end)];
? What is the purpose of that?
Ahmed Darwish
on 25 Nov 2020
Walter Roberson
on 25 Nov 2020
The first line selects the X corresponding to the class labeled 1 (in the last column of the data that is processed) and plots the first column vs the second column.
The second line is similar but the points corresponding to the class labeled -1 are plotted.
Your input data has the class information in the first column not the last column, so first you have to move the first column to become the last column. The code you posted does not do that, but obviously intended to move columns in a previous version.
Secondly your data has classes labeled 1 and 0 instead of 1 and -1. You have a choice of repairing the class labels before processing, or else of changing the plot code to deal with the classes you actually have.
Ahmed Darwish
on 25 Nov 2020
Answers (1)
Walter Roberson
on 25 Nov 2020
Edited: Walter Roberson
on 25 Nov 2020
a = a(:,[2:end,1]) ;
and
scatter(X(Y==1,1), X(Y==1,2), '*g')
scatter(X(Y==0,1), X(Y==0,2), '*r')
5 Comments
Ahmed Darwish
on 25 Nov 2020
Edited: Ahmed Darwish
on 25 Nov 2020
Ahmed Darwish
on 25 Nov 2020
Ahmed Darwish
on 25 Nov 2020
Ahmed Darwish
on 25 Nov 2020
Walter Roberson
on 25 Nov 2020
Sorry it is my bedtime
Categories
Find more on Scatter Plots 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!