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

LOF calculation

kNN is useful for finding global anomalies, but is less able to surface local outliers. In this exercise, you'll practice using the lof() function to calculate local outlier factors for the wine data.

lof() has the arguments:

  • x: the data for scoring,
  • k: the number of neighbors used to calculate the LOF.

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

Introduction to Anomaly Detection in R

ดูคอร์ส

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

  • Calculate the local outlier factor using the 5-nearest neighbors.
  • Append the LOF to the wine data set as a new column called score.

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

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

# Calculate the LOF for wine data
wine_lof <- lof(___, ___)

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