Calculate Covariance Matrix

Easy
Deep Learning

Write a Python function to calculate the covariance matrix for a given set of vectors. The function should take a list of lists, where each inner list represents a feature with its observations, and return a covariance matrix as a list of lists.

Examples

Example 1:
Input: [[1, 2, 3], [4, 5, 6]]
Output: [[1.0, 1.0], [1.0, 1.0]]
Explanation: The covariance between the two features is calculated based on their deviations from the mean. For the given vectors, both covariances are 1.0, resulting in a symmetric covariance matrix.

Starter Code

def calculate_covariance_matrix(vectors: list[list[float]]) -> list[list[float]]:
	# Your code here
	return []
Lines: 1Characters: 0
Ready
The AI Interview - Master AI/ML Interviews