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

Appending the kNN score

Now you've standardized your input features, it's time to create the kNN distance score for the standardized wine data and append it as a new column.

In this exercise, the 5 nearest neighbor distance score is already available in the object wine_nnd. So that the score is easily available for visualization or further analysis, you'll append the score as a new column to the unstandardized data.

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

Introduction to Anomaly Detection in R

ดูคอร์ส

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

  • Add the 5-nearest neighbor score to the wine dataframe as a new column called score.

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

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

# Print the 5-nearest neighbor distance score
wine_nnd[1:5]

# Append the score as a new column 
แก้ไขและรันโค้ด