Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/06/09 09:49:51 (15 years ago)
Author:
gkronber
Message:

Fixed #773 (SVM predictor doesn't work correctly if the target variable contains NaN values)

Location:
trunk/sources/HeuristicLab.SupportVectorMachines/3.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/Predictor.cs

    r2381 r2412  
    7575      }
    7676
     77
    7778      Problem p = SVMHelper.CreateSVMProblem(input, input.GetVariableIndex(targetVariable), newIndex,
    7879        start, end, minTimeOffset, maxTimeOffset);
    7980      Problem scaledProblem = SVM.Scaling.Scale(p, transform);
    8081
     82      int targetVariableIndex = input.GetVariableIndex(targetVariable);
    8183      int rows = end - start;
    82       int columns = input.Columns;
    8384      double[] result = new double[rows];
    84       for (int row = 0; row < rows; row++) {
    85         result[row] = Math.Max(Math.Min(SVM.Prediction.Predict(model, scaledProblem.X[row]), UpperPredictionLimit), LowerPredictionLimit);
     85      int problemRow = 0;
     86      for (int resultRow = 0; resultRow < rows; resultRow++) {
     87        if (double.IsNaN(input.GetValue(resultRow, targetVariableIndex)))
     88          result[resultRow] = UpperPredictionLimit;
     89        else
     90          result[resultRow] = Math.Max(Math.Min(SVM.Prediction.Predict(model, scaledProblem.X[problemRow++]), UpperPredictionLimit), LowerPredictionLimit);
    8691      }
    8792      return result;
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SVMHelper.cs

    r2349 r2412  
    2424      }
    2525
    26       int maxColumns = (dataset.Columns - skippedFeatures.Count()) * (maxTimeOffset - minTimeOffset + 1);
     26      int maxColumns = 0;
    2727
    2828      double[] targetVector = new double[rowCount];
     
    4444              int actualColumn = columnMapping[col] * (maxTimeOffset - minTimeOffset + 1) + (timeOffset - minTimeOffset);
    4545              double value = dataset.GetValue(start + row + timeOffset, col);
    46               if (!double.IsNaN(value))
     46              if (!double.IsNaN(value)) {
    4747                tempRow.Add(new SVM.Node(actualColumn, value));
     48                if (actualColumn > maxColumns) maxColumns = actualColumn;
     49              }
    4850            }
    4951          }
Note: See TracChangeset for help on using the changeset viewer.