Changeset 8829 for trunk/sources
- Timestamp:
- 10/22/12 16:12:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/Scaling.cs
r8463 r8829 44 44 foreach (var variable in variables) { 45 45 var values = ds.GetDoubleValues(variable, rows); 46 var min = values. Min();47 var max = values. Max();46 var min = values.Where(x => !double.IsNaN(x)).Min(); 47 var max = values.Where(x => !double.IsNaN(x)).Max(); 48 48 scalingParameters[variable] = Tuple.Create(min, max); 49 49 } … … 57 57 double min = scalingParameters[variable].Item1; 58 58 double max = scalingParameters[variable].Item2; 59 return ds.GetDoubleValues(variable, rows).Select(x => (x - min) / (max - min)); 59 if (min.IsAlmost(max)) return rows.Select(i => 0.0); // return enumerable of zeros 60 return ds.GetDoubleValues(variable, rows).Select(x => (x - min) / (max - min)); // scale to range [0..1] 60 61 } 61 62
Note: See TracChangeset
for help on using the changeset viewer.