data_all = [data.Radius data.Texture data.Perimeter data.Area data.Smoothness ...
data.Compactness data.Concavity data.ConcavePoints data.Symmetry data.Fractal data.Diagnosis];
train_all = [train.Radius train.Texture train.Perimeter train.Area train.Smoothness ...
train.Compactness train.Concavity train.ConcavePoints train.Symmetry train.Fractal train.Diagnosis];
ntrain=max(size(train_all));
ndata=max(size(data_all));
rmse=0;
for i = 1:ntrain
	val=train_all(i,1:10);
	for j = 1:ndata
		dist(j) = norm(data_all(j,1:10)-val);
	end
	[t,idx]=sort(dist);
	y=data_all(idx,11);
	y_predict(i) = y(1);
	if train_all(i,11) == y(1)       % check if predicted is correct
		rmse = rmse + 1;
	end
end
rmse=100*rmse/ntrain;
figure
plot(train_all(:,11),y_predict,'or','LineWidth',1.5);
xlabel('Actual diagnostic')
ylabel('Predicted diagnostic')
title("RMSE = " + rmse);

