concept
Dimensionality and anomaly detection
Centered projection onto the x axis; a PCA direction for the specific diagonal covariance fixture, not a general PCA fit.
Formal Syntax & Structure
artificial-intelligence syntaxartificial-intelligence
project_x(points, mean_x)Working Example
Example Snippetartificial-intelligence
def project_x(points, mean_x): return [x - mean_x for x, y in points]
points = [(-2, -1), (-2, 1), (2, -1), (2, 1)]mean_x = sum(x for x, y in points) / len(points)mean_y = sum(y for x, y in points) / len(points)scores = project_x(points, mean_x)var_x = sum((x - mean_x)**2 for x, y in points) / len(points)var_y = sum((y - mean_y)**2 for x, y in points) / len(points)print(scores)print(var_x / (var_x + var_y))