НачатьНачать бесплатно

LOF with factors

The lof() function can accept either a numeric data frame or a distance matrix as input to calculate LOF scores. In this exercise, you'll practice calculating a distance matrix using Gower's distance, which can then be passed to the lof() function for scoring.

As in the previous exercise, the thyroid data with character columns converted to factors has been preloaded for you to use.

Это упражнение является частью курса

Introduction to Anomaly Detection in R

Посмотреть курс

Инструкции к упражнению

  • Calculate Gower's distance matrix for the thyroid data, assign the result to the new object thyroid_dist.
  • Use thyroid_dist to generate a LOF for each patient assuming k = 10.
  • Print the range of the distances contains in the matrix thyroid_dist.

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Calculate Gower's distance matrix
thyroid_dist <- daisy(___, metric = ___)

# Generate LOF scores for thyroid data
thyroid_lof <- lof(thyroid_dist, k = 10)

# Range of values in the distance matrix
___(as.matrix(___))
Редактировать и запускать код