import numpy as np
features = np.array([
[120.0, 3.0, 10.0],
[90.0, 5.0, 7.0],
[150.0, 2.0, 14.0],
])
mean = features.mean(axis=0)
std = features.std(axis=0)
standardized = (features - mean) / std
weights = np.array([0.5, 1.5, 2.0])
weighted_score = standardized * weights
final_score = weighted_score.sum(axis=1)
print(final_score)
Good NumPy code replaces Python loops with array semantics that are easier to optimize and easier to benchmark. Broadcasting is the feature that makes those transformations elegant. I rely on it for normalization, distance calculations, and matrix-friendly preprocessing when raw speed matters.