Kom igångKom igång gratis

Visualizing kNN distance score

The kNN distance score can be hard to interpret by simply eyeballing a set of values. It's helpful to use scatterplots to visualize the kNN distance score to understand how the score works. When interpreting the plot, the relative size of the kNN distance score is more informative than the absolute value.

The wine data has been loaded with the kNN distance score appended from the previous exercise.

Den här övningen är en del av kursen

Introduction to Anomaly Detection in R

Visa kurs

Övningsinstruktioner

  • Use a scatterplot to show pH and alcohol on their original scales.
  • Supply an appropriate value to the cex argument so that each point is proportional in size to the square root of the score.
  • Adjust the plotting character argument pch so that points are shown as solid bullets.

Interaktiv övning med praktiskt arbete

Testa den här övningen genom att slutföra den här exempelkoden.

# Scatterplot showing pH, alcohol and kNN score
plot(pH ~ alcohol, ___, cex = ___, pch = ___)
Redigera och kör kod