Sección 1. Capítulo 8
single
Challenge: Mahalanobis Distance in Practice
Desliza para mostrar el menú
Tarea
Desliza para comenzar a programar
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.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 8
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla