Section 1. Chapitre 8
single
Challenge: Mahalanobis Distance in Practice
Glissez pour afficher le menu
Tâche
Glissez pour commencer à coder
You are given a small 2D dataset. Your goal is to compute the Mahalanobis distance of each observation from the data center and use it to detect outliers.
Steps:
- Compute the mean vector of the dataset.
- Compute the covariance matrix and its inverse.
- For each observation, compute Mahalanobis distance using the formula:
- Store all distances in an array
distances. - Classify points as outliers if
distance > threshold(usethreshold = 2.5). - Print both arrays (
distancesandoutliers) for verification.
Use NumPy only.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 8
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion