Closed tikigonzo closed 3 weeks ago
This normalize method is implementing Min-Max scaling.
Looks like you might be testing the wrong things. Try running this test:
[TestMethod] public void Test_Normalize_Denormalize() { var trueData = new double[] { 0, 250, 500, 750, 1000 }; var trueNorm = new double[] { 0, 0.25, 0.5, 0.75, 1.0 };
// Test normalization
var dataNorm = Tools.Normalize(trueData);
for (int i = 0; i < trueData.Length; i++)
{
Assert.AreEqual(trueNorm[i], dataNorm[i]);
}
// Test de-normalization
var dataDenorm = Tools.Denormalize(dataNorm, Tools.Min(trueData), Tools.Max(trueData));
for (int i = 0; i < trueData.Length; i++)
{
Assert.AreEqual(trueData[i], dataDenorm[i]);
}
}
An additional reference: https://www.codecademy.com/article/normalization
Its doing min-max normalization. The standardize method is doing "z-score normalization" shown in this link.
The Normalize() method in Tools.cs is supposed to return the normalized values from the vector or list. The current method updates the array with the values[i] - minimum value / max - min value. I tried to rewrite my own method to pass a unit test underneath the other one.