I'm struggling to develop a function that can normalize features within a dataset, ensuring they fall between 0 and 1. My goal is to iterate through all the features and update their values as I perform normalization. While the normalization process itself is successful, I am facing challenges in replacing the original values with the normalized ones.
Data.prototype.normalize = function(dataset) {
// Calculate the extent for each feature
for (var feature = 0; feature < this.featureCount; feature++) {
var extent = this.getExtent(feature, dataset),
min = extent[0],
max = extent[1];
// Normalize the feature values for all companies using the calculated extent
for (var company = 0; company < this.companies.length; company++) {
var value = this.companies[company][dataset][feature],
normalized = this.normalizeValue(value, min, max);
value = normalized;
}
}
}
The issue arises at
value = normalized;
While logging the updated value shows success within the function scope, the changes do not persist outside of it.
data.companies[n] = { features : [1, 2, 3, 4, 5], other properties... }
An example of the feature array within my main object is provided above. Any suggestions on resolving this problem would be greatly appreciated.
Thank you!