Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/04/13 15:16:49 (12 years ago)
Author:
abeham
Message:

#1913: removed scaling of data

Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/INcaInitializer.cs

    r9270 r9272  
    3131    /// <param name="dimensions">The amount of columns in the matrix</param>
    3232    /// <returns>The matrix that projects the input variables into a lower dimensional space.</returns>
    33     double[,] Initialize(IClassificationProblemData data, Scaling scaling, int dimensions);
     33    double[,] Initialize(IClassificationProblemData data, int dimensions);
    3434  }
    3535}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/LdaInitializer.cs

    r9270 r9272  
    4040    }
    4141
    42     public override double[,] Initialize(IClassificationProblemData data, Scaling scaling, int dimensions) {
     42    public override double[,] Initialize(IClassificationProblemData data, int dimensions) {
    4343      var instances = data.TrainingIndices.Count();
    4444      var attributes = data.AllowedInputVariables.Count();
    4545
    46       var ldaDs = new double[instances, attributes + 1];
    47       int j = 0;
    48       foreach (var a in data.AllowedInputVariables) {
    49         int i = 0;
    50         var sv = scaling.GetScaledValues(data.Dataset, a, data.TrainingIndices);
    51         foreach (var v in sv) {
    52           ldaDs[i++, j] = v;
    53         }
    54         j++;
    55       }
    56       j = 0;
    57       foreach (var tv in data.Dataset.GetDoubleValues(data.TargetVariable, data.TrainingIndices))
    58         ldaDs[j++, attributes] = tv;
     46      var ldaDs = AlglibUtil.PrepareInputMatrix(data.Dataset,
     47                                                data.AllowedInputVariables.Concat(data.TargetVariable.ToEnumerable()),
     48                                                data.TrainingIndices);
    5949
    6050      var uniqueClasses = data.Dataset.GetDoubleValues(data.TargetVariable, data.TrainingIndices).Distinct().Count();
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/NcaInitializer.cs

    r9270 r9272  
    4343      get { return (ILookupParameter<RealVector>)Parameters["NcaMatrix"]; }
    4444    }
    45     public ILookupParameter<Scaling> ScalingParameter {
    46       get { return (ILookupParameter<Scaling>)Parameters["Scaling"]; }
    47     }
    4845
    4946    [StorableConstructor]
     
    5451      Parameters.Add(new LookupParameter<IntValue>("Dimensions", "The number of dimensions to which the features should be pruned."));
    5552      Parameters.Add(new LookupParameter<RealVector>("NcaMatrix", "The coefficients of the matrix that need to be optimized. Note that the matrix is flattened."));
    56       Parameters.Add(new LookupParameter<Scaling>("Scaling", "Each dataset is scaled and the information is stored in a scaling object."));
    5753    }
    5854
    5955    public override IOperation Apply() {
    6056      var problemData = ProblemDataParameter.ActualValue;
    61       var scaling = new Scaling(problemData.Dataset, problemData.AllowedInputVariables, problemData.TrainingIndices);
    6257
    6358      var dimensions = DimensionsParameter.ActualValue.Value;
    64       var matrix = Initialize(problemData, scaling, dimensions);
     59      var matrix = Initialize(problemData, dimensions);
    6560      var attributes = matrix.GetLength(0);
    6661
     
    7065          result[i * dimensions + j] = matrix[i, j];
    7166
    72       ScalingParameter.ActualValue = scaling;
    7367      NcaMatrixParameter.ActualValue = new RealVector(result);
    7468      return base.Apply();
    7569    }
    7670
    77     public abstract double[,] Initialize(IClassificationProblemData data, Scaling scaling, int dimensions);
     71    public abstract double[,] Initialize(IClassificationProblemData data, int dimensions);
    7872  }
    7973}
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/PcaInitializer.cs

    r9270 r9272  
    4040    }
    4141
    42     public override double[,] Initialize(IClassificationProblemData data, Scaling scaling, int dimensions) {
     42    public override double[,] Initialize(IClassificationProblemData data, int dimensions) {
    4343      var instances = data.TrainingIndices.Count();
    4444      var attributes = data.AllowedInputVariables.Count();
    4545
    46       var pcaDs = AlglibUtil.PrepareAndScaleInputMatrix(data.Dataset, data.AllowedInputVariables, data.TrainingIndices, scaling);
     46      var pcaDs = AlglibUtil.PrepareInputMatrix(data.Dataset, data.AllowedInputVariables, data.TrainingIndices);
    4747
    4848      int info;
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/RandomInitializer.cs

    r9270 r9272  
    4848    }
    4949
    50     public override double[,] Initialize(IClassificationProblemData data, Scaling scaling, int dimensions) {
     50    public override double[,] Initialize(IClassificationProblemData data, int dimensions) {
    5151      var attributes = data.AllowedInputVariables.Count();
    5252
Note: See TracChangeset for help on using the changeset viewer.