Re: [R] Outlier Detection with k-Means

2014-05-08 Thread marioger
Thank you very much. This was exactly what I was looking for. -- View this message in context: http://r.789695.n4.nabble.com/Outlier-Detection-with-k-Means-tp4690098p4690186.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-pr

Re: [R] Outlier Detection with k-Means

2014-05-07 Thread Boris Steipe
Oops. > (ii) Your distance calculation is not the cartesian distance. That would be: > sqrt(rowSums(iris2[1,]^2 - centers[1,]^2)). Strike that. Need more coffee :-O > On 2014-05-07, at 4:34 AM, marioger wrote: > >> Hi, >> >> i am hoping you can help me with my problem. I am trying to

Re: [R] Outlier Detection with k-Means

2014-05-07 Thread Boris Steipe
Three comments: (i)If you calculate distances like this, you are weighting all columns equally by absolute numbers. Depending on your application, you might want to normalize the columns first (and before clustering). (ii) Your distance calculation is not the cartesian distance

Re: [R] Outlier Detection with k-Means

2014-05-07 Thread William Dunlap
Try replacing your order() call with the following 2 lines meanClusterRadius <- ave(distances, kmeans.result$cluster, FUN = mean) outliers <- order(distances/meanClusterRadius, decreasing = T)[1:5] ave(x,group,FUN=fun) applies FUN to the subsets of x defined by the group argument(s) and pu