// init new features
int featuresSize = instance.features.length;
double[] standardizedFeatures = new double[featuresSize];
// Standardize each feature
StreamFeatureStatistics featureStatistics;
for (int i = 0; i < featuresSize; i++) {
featureStatistics = streamStatistics.getFeaturesStatistics().get(i);
standardizedFeatures[i] = (instance.features[i] - featureStatistics.getMean()) / featureStatistics.getStdDev();
}
Instance<?> standardizedInstance = new Instance(instance.label, standardizedFeatures);
return standardizedInstance;
}