Changeset 14400 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs
- Timestamp:
- 11/17/16 15:41:33 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs
r14393 r14400 119 119 if (IsCompatibilityLoaded) { 120 120 // no scaling 121 inputMatrix = dataset.ToArray(121 inputMatrix = AlglibUtil.PrepareInputMatrix(dataset, 122 122 this.allowedInputVariables.Concat(new string[] { targetVariable }), 123 123 rows); … … 167 167 168 168 private static double[,] CreateScaledData(IDataset dataset, IEnumerable<string> variables, IEnumerable<int> rows, double[] offsets, double[] factors) { 169 var transforms = 170 variables.Select( 171 (_, colIdx) => 172 new LinearTransformation(variables) { Addend = offsets[colIdx] * factors[colIdx], Multiplier = factors[colIdx] }); 173 return dataset.ToArray(variables, transforms, rows); 169 var x = new double[rows.Count(), variables.Count()]; 170 var colIdx = 0; 171 foreach (var variableName in variables) { 172 var rowIdx = 0; 173 foreach (var val in dataset.GetDoubleValues(variableName, rows)) { 174 x[rowIdx, colIdx] = (val + offsets[colIdx]) * factors[colIdx]; 175 rowIdx++; 176 } 177 colIdx++; 178 } 179 return x; 174 180 } 175 181 … … 181 187 double[,] inputData; 182 188 if (IsCompatibilityLoaded) { 183 inputData = dataset.ToArray(allowedInputVariables, rows);189 inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 184 190 } else { 185 191 inputData = CreateScaledData(dataset, allowedInputVariables, rows, offsets, weights); … … 217 223 double[,] inputData; 218 224 if (IsCompatibilityLoaded) { 219 inputData = dataset.ToArray(allowedInputVariables, rows);225 inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 220 226 } else { 221 227 inputData = CreateScaledData(dataset, allowedInputVariables, rows, offsets, weights);
Note: See TracChangeset
for help on using the changeset viewer.