Seksjon 1. Kapittel 8
single
Challenge: Mahalanobis Distance in Practice
Sveip for å vise menyen
Oppgave
Sveip for å begynne å kode
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.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 8
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår