- Timestamp:
- 03/04/13 15:16:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/NcaModel.cs
r8528 r9272 33 33 34 34 [Storable] 35 private Scaling scaling;36 [Storable]37 35 private double[,] transformationMatrix; 38 36 public double[,] TransformationMatrix { … … 52 50 protected NcaModel(NcaModel original, Cloner cloner) 53 51 : base(original, cloner) { 54 this.scaling = cloner.Clone(original.scaling);55 52 this.transformationMatrix = (double[,])original.transformationMatrix.Clone(); 56 53 this.allowedInputVariables = (string[])original.allowedInputVariables.Clone(); … … 59 56 this.classValues = (double[])original.classValues.Clone(); 60 57 } 61 public NcaModel(int k, double[,] transformationMatrix, Dataset dataset, IEnumerable<int> rows, string targetVariable, IEnumerable<string> allowedInputVariables, Scaling scaling,double[] classValues) {58 public NcaModel(int k, double[,] transformationMatrix, Dataset dataset, IEnumerable<int> rows, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues) { 62 59 Name = ItemName; 63 60 Description = ItemDescription; 64 this.scaling = scaling;65 61 this.transformationMatrix = (double[,])transformationMatrix.Clone(); 66 62 this.allowedInputVariables = allowedInputVariables.ToArray(); … … 90 86 91 87 public double[,] Reduce(Dataset dataset, IEnumerable<int> rows) { 92 var scaledData = AlglibUtil.PrepareAndScaleInputMatrix(dataset, allowedInputVariables, rows, scaling); 88 var data = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 89 93 90 var targets = dataset.GetDoubleValues(targetVariable, rows).ToArray(); 94 var result = new double[ scaledData.GetLength(0), transformationMatrix.GetLength(1) + 1];95 for (int i = 0; i < scaledData.GetLength(0); i++)96 for (int j = 0; j < scaledData.GetLength(1); j++) {91 var result = new double[data.GetLength(0), transformationMatrix.GetLength(1) + 1]; 92 for (int i = 0; i < data.GetLength(0); i++) 93 for (int j = 0; j < data.GetLength(1); j++) { 97 94 for (int x = 0; x < transformationMatrix.GetLength(1); x++) { 98 result[i, x] += scaledData[i, j] * transformationMatrix[j, x];95 result[i, x] += data[i, j] * transformationMatrix[j, x]; 99 96 } 100 97 result[i, transformationMatrix.GetLength(1)] = targets[i];
Note: See TracChangeset
for help on using the changeset viewer.