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

Walter Roberson
Walter Roberson 2020년 11월 25일
Could you link to the documentation for the holdout() function you are using?
a=[a(:,1:end-1),a(:,end)];
? What is the purpose of that?
I am not understanding what these two lines mean and their role in data scattering. I am really sorry if I sound ignorant. Any kind of help would be greatly appreciated, Please.
scatter(X(Y==1,1),X(Y==1,2),'*g')
scatter(X(Y==-1,1),X(Y==-1,2),'*r')
Walter Roberson
Walter Roberson 2020년 11월 25일
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
Ahmed Darwish 2020년 11월 25일
I will study on this.Many many thanks and gratitude for your explanation. Could you please suggest me a code to fix my problem according to my data so that I can have a scatter plot. I am really strugling with this since last two weeks, and tommorow is the deadline to submit my assignment. Sorry to ask you. But, I would be really greatful.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2020년 11월 25일
편집: Walter Roberson 2020년 11월 25일

0 개 추천

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

Ahmed Darwish
Ahmed Darwish 2020년 11월 25일
편집: Ahmed Darwish 2020년 11월 25일
Sorry for my late reply. Here is the link you asked for. Thanks a lot for your help. I really appriciate it. I am trying to use non-linear.Hold_out function
Ahmed Darwish
Ahmed Darwish 2020년 11월 25일
I am really sorry. But, unfortunately the code you suggested only shows a red dot. I tried many values with trial and error by changing the value of Y, without any success.
Ahmed Darwish
Ahmed Darwish 2020년 11월 25일
I got it. Thanks a lot, for your help. Your explanation was clear and very helpful. My gratitude and many thanks again.
Ahmed Darwish
Ahmed Darwish 2020년 11월 25일
Hello, Walter Roberson. I only get few scattering like 8-10 points. If you don't mind and have some free time, could you please provide me a solution/code to plot the scattering plot for my data class. I am a biomedical student, very very weak in machine learning. Sorry, for my ignorance. I really appreciate all of help and guideline.
Walter Roberson
Walter Roberson 2020년 11월 25일
Sorry it is my bedtime

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

2020년 11월 25일

댓글:

2020년 11월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by