R-Help Does one need to normalize ones data is using the knn function within the caret Library. Jeff [[alternative HTML version deleted]]
It depends on what you are trying to do and what kind of data you are using. If you are using Euclidian distance and your variables have different means and standard deviations, the answer is probably yes. That will weight each variable equally. Without standardization the variables with the larger magnitudes will determine the groups more than the variables with the smaller magnitudes. David L. Carlson Department of Anthropology Texas A&M University -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Jeff Reichman Sent: Thursday, June 21, 2018 11:36 AM To: R-help at r-project.org Subject: [R] KNN R-Help Does one need to normalize ones data is using the knn function within the caret Library. Jeff [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Yes, however using caret you can do it directly using the preProcess parameter, e.g. train(y ~., data = train, method = "knn", preProcess = c("center", "scale")). Hope this helps. Eivind On Thu, 21 Jun 2018, Jeff Reichman wrote:> R-Help > > > > Does one need to normalize ones data is using the knn function within the > caret Library. > > > > Jeff > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
David I figured out where I went wrong. But thank you for the response Jeff -----Original Message----- From: David L Carlson <dcarlson at tamu.edu> Sent: Thursday, June 21, 2018 11:43 AM To: reichmanj at sbcglobal.net; R-help at r-project.org Subject: RE: [R] KNN It depends on what you are trying to do and what kind of data you are using If you are using Euclidian distance and your variables have different means and standard deviations, the answer is probably yes. That will weight each variable equally. Without standardization the variables with the larger magnitudes will determine the groups more than the variables with the smaller magnitudes. David L. Carlson Department of Anthropology Texas A&M University -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Jeff Reichman Sent: Thursday, June 21, 2018 11:36 AM To: R-help at r-project.org Subject: [R] KNN R-Help Does one need to normalize ones data is using the knn function within the caret Library. Jeff [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.