- Timestamp:
- 04/11/17 15:55:44 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs
r14826 r14843 119 119 if (IsCompatibilityLoaded) { 120 120 // no scaling 121 inputMatrix = AlglibUtil.PrepareInputMatrix(dataset,121 inputMatrix = dataset.ToArray( 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 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; 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); 180 174 } 181 175 … … 187 181 double[,] inputData; 188 182 if (IsCompatibilityLoaded) { 189 inputData = AlglibUtil.PrepareInputMatrix(dataset,allowedInputVariables, rows);183 inputData = dataset.ToArray(allowedInputVariables, rows); 190 184 } else { 191 185 inputData = CreateScaledData(dataset, allowedInputVariables, rows, offsets, weights); … … 223 217 double[,] inputData; 224 218 if (IsCompatibilityLoaded) { 225 inputData = AlglibUtil.PrepareInputMatrix(dataset,allowedInputVariables, rows);219 inputData = dataset.ToArray(allowedInputVariables, rows); 226 220 } else { 227 221 inputData = CreateScaledData(dataset, allowedInputVariables, rows, offsets, weights);
Note: See TracChangeset
for help on using the changeset viewer.