data=csvRead("C:\Users\USER\Desktop\Iris.csv",",","%f");
Is the code I used in Scilab to read the file which contains this:
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
and so on...
now what I want to do is to manipulate the data by row and apply it to a clustering algorithm. For example I want to use each of the values in row one to calculate their euclidian distance between the centroids.
How would I know the index of each value and how do use it in computations?
I want to manipulate the data just like this code in Java.
for(i=0; i < popnSize; i++){
for(j=0; j < dim; j++){
System.out.println("["+i+"]" + arrpop[i][j]+"\t");
}
How would you translate that in Scilab after reading the matrix using csvRead?
After
--> data=csvRead("C:\Users\USER\Desktop\Iris.csv",",","%f");
computing the distance to the centroid can be done by centering the data matrix in the row direction then computing the norm of each row:
--> dist = sqrt(sum(center(data(:,1:4),1).^2,2))
dist =
0.6407461
0.7168604
0.8566732
0.8065702
0.7074995
3.4274221