Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/15/16 21:23:43 (8 years ago)
Author:
gkronber
Message:

#2697:

  • removed AlglibUtil.cs and added an extension method .ToArray(names, rows) to IDataset instead.
  • refactored transformation so that it is possible to apply an transformation without resetting the parameters
  • Used transformations instead of Scaling as far as possible.
  • Moved TakeEvery extension method to HL.Common
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs

    r14185 r14393  
    165165      try {
    166166        CalculateModel(ds, rows, scaleInputs);
    167       }
    168       catch (alglib.alglibexception ae) {
     167      } catch (alglib.alglibexception ae) {
    169168        // wrap exception so that calling code doesn't have to know about alglib implementation
    170169        throw new ArgumentException("There was a problem in the calculation of the Gaussian process model", ae);
     
    260259    private static double[,] GetData(IDataset ds, IEnumerable<string> allowedInputs, IEnumerable<int> rows, Scaling scaling) {
    261260      if (scaling != null) {
    262         return AlglibUtil.PrepareAndScaleInputMatrix(ds, allowedInputs, rows, scaling);
     261        // TODO: completely remove Scaling class
     262        List<ITransformation<double>> transformations = new List<ITransformation<double>>();
     263
     264        foreach (var varName in allowedInputs) {
     265          double min;
     266          double max;
     267          scaling.GetScalingParameters(varName, out min, out max);
     268          var add = -min / (max - min);
     269          var mult = 1.0 / (max - min);
     270          transformations.Add(new LinearTransformation(allowedInputs) { Addend = add, Multiplier = mult });
     271        }
     272        return ds.ToArray(allowedInputs, transformations, rows);
    263273      } else {
    264         return AlglibUtil.PrepareInputMatrix(ds, allowedInputs, rows);
     274        return ds.ToArray(allowedInputs, rows);
    265275      }
    266276    }
     
    334344        return Enumerable.Range(0, newN)
    335345          .Select(i => ms[i] + Util.ScalarProd(Ks[i], alpha));
    336       }
    337       catch (alglib.alglibexception ae) {
     346      } catch (alglib.alglibexception ae) {
    338347        // wrap exception so that calling code doesn't have to know about alglib implementation
    339348        throw new ArgumentException("There was a problem in the calculation of the Gaussian process model", ae);
     
    381390        }
    382391        return kss;
    383       }
    384       catch (alglib.alglibexception ae) {
     392      } catch (alglib.alglibexception ae) {
    385393        // wrap exception so that calling code doesn't have to know about alglib implementation
    386394        throw new ArgumentException("There was a problem in the calculation of the Gaussian process model", ae);
Note: See TracChangeset for help on using the changeset viewer.