Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15783


Ignore:
Timestamp:
02/16/18 11:35:54 (6 years ago)
Author:
fholzing
Message:

#2902: Changed from Cast to Iterator and adapted all occurrences.

Location:
trunk/HeuristicLab.Algorithms.DataAnalysis/3.4
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r15532 r15783  
    131131      <SubType>Code</SubType>
    132132    </Compile>
     133    <Compile Include="DoubleArrayExtensions.cs" />
    133134    <Compile Include="FixedDataAnalysisAlgorithm.cs" />
    134135    <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceSpectralMixture.cs" />
     
    320321    <Compile Include="TSNE\Distances\IndexedItemDistance.cs" />
    321322    <Compile Include="TSNE\Distances\ManhattanDistance.cs" />
    322   <Compile Include="TSNE\Distances\WeightedEuclideanDistance.cs" />
     323    <Compile Include="TSNE\Distances\WeightedEuclideanDistance.cs" />
    323324    <Compile Include="TSNE\Distances\IDistance.cs" />
    324325    <Compile Include="TSNE\PriorityQueue.cs" />
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearDiscriminantAnalysis.cs

    r15583 r15783  
    8080      inputMatrix = factorMatrix.HorzCat(inputMatrix);
    8181
    82       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     82      if (inputMatrix.ContainsNanInf())
    8383        throw new NotSupportedException("Linear discriminant analysis does not support NaN or infinity values in the input dataset.");
    8484
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs

    r15583 r15783  
    8080      var inputMatrix = binaryMatrix.HorzCat(doubleVarMatrix);
    8181
    82       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     82      if (inputMatrix.ContainsNanInf())
    8383        throw new NotSupportedException("Linear regression does not support NaN or infinity values in the input dataset.");
    8484
     
    100100      int nVarCoeff = doubleVariables.Count();
    101101      var tree = LinearModelToTreeConverter.CreateTree(factorVariables, coefficients.Take(nFactorCoeff).ToArray(),
    102         doubleVariables.ToArray(), coefficients.Skip(nFactorCoeff).Take(nVarCoeff).ToArray(), 
     102        doubleVariables.ToArray(), coefficients.Skip(nFactorCoeff).Take(nVarCoeff).ToArray(),
    103103        @const: coefficients[nFeatures]);
    104      
     104
    105105      SymbolicRegressionSolution solution = new SymbolicRegressionSolution(new SymbolicRegressionModel(problemData.TargetVariable, tree, new SymbolicDataAnalysisExpressionTreeLinearInterpreter()), (IRegressionProblemData)problemData.Clone());
    106106      solution.Model.Name = "Linear Regression Model";
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitClassification.cs

    r15583 r15783  
    7878      inputMatrix = factorMatrix.HorzCat(inputMatrix);
    7979
    80       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     80      if (inputMatrix.ContainsNanInf())
    8181        throw new NotSupportedException("Multinomial logit classification does not support NaN or infinity values in the input dataset.");
    8282
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs

    r15583 r15783  
    142142      }
    143143
    144       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     144      if (inputMatrix.ContainsNanInf())
    145145        throw new NotSupportedException(
    146146          "Nearest neighbour model does not support NaN or infinity values in the input dataset.");
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassification.cs

    r15583 r15783  
    115115    public NeuralNetworkClassification()
    116116      : base() {
    117       var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { 
    118         (IntValue)new IntValue(0).AsReadOnly(), 
    119         (IntValue)new IntValue(1).AsReadOnly(), 
     117      var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] {
     118        (IntValue)new IntValue(0).AsReadOnly(),
     119        (IntValue)new IntValue(1).AsReadOnly(),
    120120        (IntValue)new IntValue(2).AsReadOnly() });
    121121      var selectedHiddenLayerValue = (from v in validHiddenLayerValues
     
    185185      IEnumerable<int> rows = problemData.TrainingIndices;
    186186      double[,] inputMatrix = dataset.ToArray(allowedInputVariables.Concat(new string[] { targetVariable }), rows);
    187       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     187      if (inputMatrix.ContainsNanInf())
    188188        throw new NotSupportedException("Neural network classification does not support NaN or infinity values in the input dataset.");
    189189
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassification.cs

    r15583 r15783  
    171171      IEnumerable<int> rows = problemData.TrainingIndices;
    172172      double[,] inputMatrix = dataset.ToArray(allowedInputVariables.Concat(new string[] { targetVariable }), rows);
    173       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     173      if (inputMatrix.ContainsNanInf())
    174174        throw new NotSupportedException("Neural network ensemble classification does not support NaN or infinity values in the input dataset.");
    175175
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegression.cs

    r15583 r15783  
    125125    public NeuralNetworkEnsembleRegression()
    126126      : base() {
    127       var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { 
    128         (IntValue)new IntValue(0).AsReadOnly(), 
    129         (IntValue)new IntValue(1).AsReadOnly(), 
     127      var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] {
     128        (IntValue)new IntValue(0).AsReadOnly(),
     129        (IntValue)new IntValue(1).AsReadOnly(),
    130130        (IntValue)new IntValue(2).AsReadOnly() });
    131131      var selectedHiddenLayerValue = (from v in validHiddenLayerValues
     
    170170      IEnumerable<int> rows = problemData.TrainingIndices;
    171171      double[,] inputMatrix = dataset.ToArray(allowedInputVariables.Concat(new string[] { targetVariable }), rows);
    172       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     172      if (inputMatrix.ContainsNanInf())
    173173        throw new NotSupportedException("Neural network ensemble regression does not support NaN or infinity values in the input dataset.");
    174174
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegression.cs

    r15583 r15783  
    115115    public NeuralNetworkRegression()
    116116      : base() {
    117       var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { 
    118         (IntValue)new IntValue(0).AsReadOnly(), 
    119         (IntValue)new IntValue(1).AsReadOnly(), 
     117      var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] {
     118        (IntValue)new IntValue(0).AsReadOnly(),
     119        (IntValue)new IntValue(1).AsReadOnly(),
    120120        (IntValue)new IntValue(2).AsReadOnly() });
    121121      var selectedHiddenLayerValue = (from v in validHiddenLayerValues
     
    186186      IEnumerable<int> rows = problemData.TrainingIndices;
    187187      double[,] inputMatrix = dataset.ToArray(allowedInputVariables.Concat(new string[] { targetVariable }), rows);
    188       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     188      if (inputMatrix.ContainsNanInf())
    189189        throw new NotSupportedException("Neural network regression does not support NaN or infinity values in the input dataset.");
    190190
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs

    r15583 r15783  
    310310    public static RandomForestModel CreateClassificationModel(IClassificationProblemData problemData, int nTrees, double r, double m, int seed,
    311311      out double rmsError, out double outOfBagRmsError, out double relClassificationError, out double outOfBagRelClassificationError) {
    312       return CreateClassificationModel(problemData, problemData.TrainingIndices, nTrees, r, m, seed, 
     312      return CreateClassificationModel(problemData, problemData.TrainingIndices, nTrees, r, m, seed,
    313313        out rmsError, out outOfBagRmsError, out relClassificationError, out outOfBagRelClassificationError);
    314314    }
     
    370370
    371371    private static void AssertInputMatrix(double[,] inputMatrix) {
    372       if (inputMatrix.Cast<double>().Any(x => Double.IsNaN(x) || Double.IsInfinity(x)))
     372      if (inputMatrix.ContainsNanInf())
    373373        throw new NotSupportedException("Random forest modeling does not support NaN or infinity values in the input dataset.");
    374374    }
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/TimeSeries/AutoregressiveModeling.cs

    r15583 r15783  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
    28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2928using HeuristicLab.Optimization;
    3029using HeuristicLab.Parameters;
     
    9796        inputMatrix[i, timeOffset] = targetValues[i + problemData.TrainingPartition.Start];
    9897
    99       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     98      if (inputMatrix.ContainsNanInf())
    10099        throw new NotSupportedException("Linear regression does not support NaN or infinity values in the input dataset.");
    101100
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClustering.cs

    r15583 r15783  
    9191      int[] xyc;
    9292      double[,] inputMatrix = dataset.ToArray(allowedInputVariables, rows);
    93       if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     93      if (inputMatrix.ContainsNanInf())
    9494        throw new NotSupportedException("k-Means clustering does not support NaN or infinity values in the input dataset.");
    9595
Note: See TracChangeset for help on using the changeset viewer.