Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/20/09 11:20:13 (15 years ago)
Author:
gkronber
Message:

Fixed #784 (ProblemInjector should be changed to read variable names instead of indexes for input and target variables)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs

    r2430 r2440  
    3737
    3838    public LinearRegressionOperator() {
    39       AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
     39      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
    4040      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
    4141      AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
     
    4747
    4848    public override IOperation Apply(IScope scope) {
    49       int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
    5049      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
     50      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
     51      int targetVariableIndex = dataset.GetVariableIndex(targetVariable);
    5152      int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data;
    5253      int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data;
     
    5657      int minTimeOffset = minTimeOffsetData == null ? 0 : minTimeOffsetData.Data;
    5758
    58       List<int> allowedColumns = CalculateAllowedColumns(dataset, targetVariable, start, end);
    59       List<int> allowedRows = CalculateAllowedRows(dataset, targetVariable, allowedColumns, start, end, minTimeOffset, maxTimeOffset);
     59      List<int> allowedColumns = CalculateAllowedColumns(dataset, targetVariableIndex, start, end);
     60      List<int> allowedRows = CalculateAllowedRows(dataset, targetVariableIndex, allowedColumns, start, end, minTimeOffset, maxTimeOffset);
    6061
    6162      double[,] inputMatrix = PrepareInputMatrix(dataset, allowedColumns, allowedRows, minTimeOffset, maxTimeOffset);
    62       double[] targetVector = PrepareTargetVector(dataset, targetVariable, allowedRows);
     63      double[] targetVector = PrepareTargetVector(dataset, targetVariableIndex, allowedRows);
    6364      double[] coefficients = CalculateCoefficients(inputMatrix, targetVector);
    6465      IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList(), minTimeOffset, maxTimeOffset);
Note: See TracChangeset for help on using the changeset viewer.