Changeset 2440 for trunk/sources/HeuristicLab.SupportVectorMachines
- Timestamp:
- 10/20/09 11:20:13 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.SupportVectorMachines/3.2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.SupportVectorMachines/3.2/PredictorBuilder.cs ¶
r2421 r2440 52 52 Dataset ds = GetVariableValue<Dataset>("Dataset", scope, true); 53 53 SVMModel model = GetVariableValue<SVMModel>("SVMModel", scope, true); 54 int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;54 string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data; 55 55 int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data; 56 56 int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data; … … 61 61 double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data; 62 62 63 string targetVariableName = ds.GetVariableName(targetVariable);63 64 64 ItemList inputVariables = GetVariableValue<ItemList>("InputVariables", scope, true); 65 65 var inputVariableNames = from x in inputVariables … … 69 69 double range = ds.GetRange(targetVariable, start, end); 70 70 71 Predictor predictor = new Predictor(model, targetVariable Name, inputVariableNames, minTimeOffset, maxTimeOffset);71 Predictor predictor = new Predictor(model, targetVariable, inputVariableNames, minTimeOffset, maxTimeOffset); 72 72 predictor.LowerPredictionLimit = mean - punishmentFactor * range; 73 73 predictor.UpperPredictionLimit = mean + punishmentFactor * range; -
TabularUnified trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorCreator.cs ¶
r2421 r2440 40 40 //Dataset infos 41 41 AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In)); 42 AddVariableInfo(new VariableInfo("TargetVariable", " Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));42 AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("InputVariables", "List of allowed input variable names", typeof(ItemList), VariableKind.In)); 44 44 AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); … … 70 70 abortRequested = false; 71 71 Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true); 72 int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data; 73 ItemList inputVaribales = GetVariableValue<ItemList>("InputVariables", scope, true); 74 var inputVariableNames = from x in inputVaribales 72 string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data; 73 int targetVariableIndex = dataset.GetVariableIndex(targetVariable); 74 ItemList inputVariables = GetVariableValue<ItemList>("InputVariables", scope, true); 75 var inputVariableNames = from x in inputVariables 75 76 select ((StringData)x).Data; 76 77 int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data; … … 93 94 parameter.Probability = false; 94 95 95 SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariable , inputVariableNames, start, end, minTimeOffset, maxTimeOffset);96 SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariableIndex, inputVariableNames, start, end, minTimeOffset, maxTimeOffset); 96 97 SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem); 97 98 SVM.Problem scaledProblem = rangeTransform.Scale(problem); -
TabularUnified trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorEvaluator.cs ¶
r2421 r2440 36 36 //Dataset infos 37 37 AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In)); 38 AddVariableInfo(new VariableInfo("TargetVariable", " Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));38 AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In)); 39 39 AddVariableInfo(new VariableInfo("InputVariables", "List of allowed input variable names", typeof(ItemList), VariableKind.In)); 40 40 AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); … … 52 52 var inputVariableNames = from x in inputVariables 53 53 select ((StringData)x).Data; 54 int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data; 54 string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data; 55 int targetVariableIndex = dataset.GetVariableIndex(targetVariable); 55 56 int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data; 56 57 int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data; … … 61 62 SVMModel modelData = GetVariableValue<SVMModel>("SVMModel", scope, true); 62 63 63 SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariable , inputVariableNames, start, end, minTimeOffset, maxTimeOffset);64 SVM.Problem problem = SVMHelper.CreateSVMProblem(dataset, targetVariableIndex, inputVariableNames, start, end, minTimeOffset, maxTimeOffset); 64 65 SVM.Problem scaledProblem = modelData.RangeTransform.Scale(problem); 65 66 66 67 double[,] values = new double[scaledProblem.Count, 2]; 67 68 for (int i = 0; i < scaledProblem.Count; i++) { 68 values[i, 0] = dataset.GetValue(start + i, targetVariable );69 values[i, 0] = dataset.GetValue(start + i, targetVariableIndex); 69 70 values[i, 1] = SVM.Prediction.Predict(modelData.Model, scaledProblem.X[i]); 70 71 } -
TabularUnified trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs ¶
r2419 r2440 52 52 } 53 53 54 public intTargetVariable {55 get { return ProblemInjector.GetVariableValue< IntData>("TargetVariable", null, false).Data; }56 set { ProblemInjector.GetVariableValue< IntData>("TargetVariable", null, false).Data = value; }54 public 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 … … 78 78 } 79 79 } 80 public IEnumerable< int> AllowedVariables {80 public IEnumerable<string> AllowedVariables { 81 81 get { 82 ItemList< IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);82 ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false); 83 83 return allowedVariables.Select(x => x.Data); 84 84 } 85 85 set { 86 ItemList< IntData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<IntData>>("AllowedFeatures", null, false);87 foreach ( int x in value) allowedVariables.Add(new IntData(x));86 ItemList<StringData> allowedVariables = ProblemInjector.GetVariableValue<ItemList<StringData>>("AllowedFeatures", null, false); 87 foreach (string x in value) allowedVariables.Add(new StringData(x)); 88 88 } 89 89 }
Note: See TracChangeset
for help on using the changeset viewer.