Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3847


Ignore:
Timestamp:
05/18/10 14:09:16 (15 years ago)
Author:
gkronber
Message:

Created a static method for SVM model evaluation. #1009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineModelEvaluator.cs

    r3842 r3847  
    8282
    8383    public override IOperation Apply() {
    84       int targetVariableIndex = DataAnalysisProblemData.Dataset.GetVariableIndex(DataAnalysisProblemData.TargetVariable.Value);
    8584      int start = SamplesStart.Value;
    8685      int end = SamplesEnd.Value;
    8786
    88       SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(DataAnalysisProblemData, start, end);
    89       SVM.Problem scaledProblem = SupportVectorMachineModel.RangeTransform.Scale(problem);
     87      ValuesParameter.ActualValue = new DoubleMatrix(Evaluate(SupportVectorMachineModel, DataAnalysisProblemData, start, end));
     88      return base.Apply();
     89    }
     90
     91    public static double[,] Evaluate(SupportVectorMachineModel model, DataAnalysisProblemData problemData, int start, int end) {
     92      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, start, end);
     93      SVM.Problem scaledProblem = model.RangeTransform.Scale(problem);
     94
     95      int targetVariableIndex = problemData.Dataset.GetVariableIndex(problemData.TargetVariable.Value);
    9096
    9197      double[,] values = new double[scaledProblem.Count, 2];
    9298      for (int i = 0; i < scaledProblem.Count; i++) {
    93         values[i, 0] = DataAnalysisProblemData.Dataset[start + i, targetVariableIndex];
    94         values[i, 1] = SVM.Prediction.Predict(SupportVectorMachineModel.Model, scaledProblem.X[i]);
     99        values[i, 0] = problemData.Dataset[start + i, targetVariableIndex];
     100        values[i, 1] = SVM.Prediction.Predict(model.Model, scaledProblem.X[i]);
    95101      }
    96102
    97       ValuesParameter.ActualValue = new DoubleMatrix(values);
    98       return base.Apply();
     103      return values;
    99104    }
    100105  }
Note: See TracChangeset for help on using the changeset viewer.