Changeset 2440 for trunk/sources/HeuristicLab.LinearRegression
- Timestamp:
- 10/20/09 11:20:13 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.LinearRegression/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs
r2419 r2440 52 52 } 53 53 54 public virtual intTargetVariable {55 get { return ProblemInjector.GetVariableValue< IntData>("TargetVariable", null, false).Data; }56 set { ProblemInjector.GetVariableValue< IntData>("TargetVariable", null, false).Data = value; }54 public virtual string TargetVariable { 55 get { return ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data; } 56 set { ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data = value; } 57 57 } 58 58 … … 70 70 } 71 71 } 72 public IEnumerable< int> AllowedVariables {72 public IEnumerable<string> AllowedVariables { 73 73 get { 74 ItemList< IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);74 ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false); 75 75 return allowedVariables.Select(x => x.Data); 76 76 } 77 77 set { 78 ItemList< IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);79 foreach ( int x in value) allowedVariables.Add(new IntData(x));78 ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false); 79 foreach (string x in value) allowedVariables.Add(new StringData(x)); 80 80 } 81 81 } -
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.