Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Mahalanobis Distance in Practice | Statistical and Distance-Based Methods
Outlier and Novelty Detection in Practice

bookChallenge: Mahalanobis Distance in Practice

Uppgift

Swipe to start coding

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:

  1. Compute the mean vector of the dataset.
  2. Compute the covariance matrix and its inverse.
  3. For each observation, compute Mahalanobis distance using the formula:

[ D(x) = \sqrt{(x - \mu)^T \Sigma^{-1} (x - \mu)} ] 4. Store all distances in an array distances. 5. Classify points as outliers if distance > threshold (use threshold = 2.5). 6. Print both arrays (distances and outliers) for verification.

Use NumPy only.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 4
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me a real-world example?

close

Awesome!

Completion rate improved to 4.55

bookChallenge: Mahalanobis Distance in Practice

Svep för att visa menyn

Uppgift

Swipe to start coding

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:

  1. Compute the mean vector of the dataset.
  2. Compute the covariance matrix and its inverse.
  3. For each observation, compute Mahalanobis distance using the formula:

[ D(x) = \sqrt{(x - \mu)^T \Sigma^{-1} (x - \mu)} ] 4. Store all distances in an array distances. 5. Classify points as outliers if distance > threshold (use threshold = 2.5). 6. Print both arrays (distances and outliers) for verification.

Use NumPy only.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 4
single

single

some-alt