Many models need features on the same scale. Standardisation rescales each column to mean 0 and standard deviation 1. The catch: the mean and standard deviation must come from the training data only. Computing them on all the data leaks information from the test set and inflates your scores.
Implement a StandardScaler class like scikit-learn's:
fit(X) learns self.mean_ and self.scale_ (per-column population standard deviation, ddof=0) and returns self. Columns with zero variance get a scale of 1.0, so you never divide by zero.transform(X) returns (X - mean_) / scale_ using the fitted statistics.fit_transform(X) does both.inverse_transform(Z) undoes it.transform before fit raises RuntimeError.