เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Standardizing features

It is important to ensure that the feature inputs to the kNN distance calculation are standardized using the scale() function. Standardization ensures that features with large mean or variance do not disproportionately influence the kNN distance score.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Introduction to Anomaly Detection in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Apply the summary() function to the wine data to calculate the mean, minimum and maximum values for pH and alcohol.
  • Use the scale() function to create a standardized version of the wine data called wine_scaled.
  • Use the summary() function to wine_scaled to check that the mean and ranges have changed.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Without standardization, features have different scales
summary(wine)

# Standardize the wine columns
wine_scaled <- ___

# Standardized features have similar means and quartiles
___(___)
แก้ไขและรันโค้ด