- Timestamp:
- 10/20/09 11:20:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs
r2430 r2440 37 37 38 38 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)); 40 40 AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In)); 41 41 AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); … … 47 47 48 48 public override IOperation Apply(IScope scope) { 49 int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;50 49 Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true); 50 string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data; 51 int targetVariableIndex = dataset.GetVariableIndex(targetVariable); 51 52 int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data; 52 53 int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data; … … 56 57 int minTimeOffset = minTimeOffsetData == null ? 0 : minTimeOffsetData.Data; 57 58 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); 60 61 61 62 double[,] inputMatrix = PrepareInputMatrix(dataset, allowedColumns, allowedRows, minTimeOffset, maxTimeOffset); 62 double[] targetVector = PrepareTargetVector(dataset, targetVariable , allowedRows);63 double[] targetVector = PrepareTargetVector(dataset, targetVariableIndex, allowedRows); 63 64 double[] coefficients = CalculateCoefficients(inputMatrix, targetVector); 64 65 IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList(), minTimeOffset, maxTimeOffset);
Note: See TracChangeset
for help on using the changeset viewer.