Changeset 9161 for branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3
- Timestamp:
- 01/15/13 11:18:06 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblemData.cs
r9160 r9161 64 64 get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; } 65 65 } 66 public IFixedValueParameter<IntRange> TrainingPartitionParameter { 67 get { return (IFixedValueParameter<IntRange>)Parameters["TrainingPartition"]; } 68 } 69 public IFixedValueParameter<IntRange> TestPartitionParameter { 70 get { return (IFixedValueParameter<IntRange>)Parameters["TestPartition"]; } 71 } 66 72 #endregion 67 73 74 #region properties 68 75 public Dataset Dataset { 69 76 get { return DatasetParameter.Value; } 70 77 } 71 72 78 public ICheckedItemList<StringValue> ConditionVariables { 73 79 get { return ConditionVariablesParameter.Value; } 74 80 } 75 76 81 public ICheckedItemList<StringValue> ActionVariables { 77 82 get { return ActionVariablesParameter.Value; } 78 83 } 79 80 84 public IEnumerable<string> AllowedConditionVariables { 81 85 get { return ConditionVariables.CheckedItems.Select(x => x.Value.Value); } … … 84 88 get { return ActionVariables.CheckedItems.Select(x => x.Value.Value); } 85 89 } 90 public IntRange TrainingPartition { 91 get { return TrainingPartitionParameter.Value; } 92 } 93 public IntRange TestPartition { 94 get { return TestPartitionParameter.Value; } 95 } 96 public IEnumerable<int> TrainingIndices { 97 get { 98 return Enumerable.Range(TrainingPartition.Start, Math.Max(0, TrainingPartition.End - TrainingPartition.Start)) 99 .Where(IsTrainingSample); 100 } 101 } 102 public IEnumerable<int> TestIndices { 103 get { 104 return Enumerable.Range(TestPartition.Start, Math.Max(0, TestPartition.End - TestPartition.Start)) 105 .Where(IsTestSample); 106 } 107 } 108 public bool IsTrainingSample(int index) { 109 return index >= 0 && index < Dataset.Rows && 110 TrainingPartition.Start <= index && index < TrainingPartition.End && 111 (index < TestPartition.Start || TestPartition.End <= index); 112 } 113 public bool IsTestSample(int index) { 114 return index >= 0 && index < Dataset.Rows && 115 TestPartition.Start <= index && index < TestPartition.End; 116 } 117 #endregion 86 118 87 119 private IDictionary<int, IClassifier> fetchClassifiersCache = new Dictionary<int, IClassifier>(); … … 113 145 conditionVariables.SetItemCheckedState(x, allowedConditionVariables.Contains(x.Value)); 114 146 } 147 148 int trainingPartitionStart = 0; 149 int trainingPartitionEnd = dataset.Rows / 2; 150 int testPartitionStart = dataset.Rows / 2; 151 int testPartitionEnd = dataset.Rows; 115 152 116 153 Parameters.Add(new FixedValueParameter<Dataset>("Dataset", "", dataset)); … … 120 157 Parameters.Add(new FixedValueParameter<IntValue>("ActionLength", "", new IntValue(allowedActionVariables.Count()))); 121 158 Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "", GetBoundsMatrix(dataset, allowedConditionVariables, allowedActionVariables))); 159 Parameters.Add(new FixedValueParameter<IntRange>("TrainingPartition", "", new IntRange(trainingPartitionStart, trainingPartitionEnd))); 160 Parameters.Add(new FixedValueParameter<IntRange>("TestPartition", "", new IntRange(testPartitionStart, testPartitionEnd))); 122 161 123 162 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; … … 158 197 public IntMatrix Bounds { 159 198 get { return BoundsParameter.Value; } 199 } 200 201 public IEnumerable<IClassifier> FetchClassifier(IEnumerable<int> rows) { 202 foreach (var row in rows) { 203 yield return FetchClassifier(row); 204 } 160 205 } 161 206
Note: See TracChangeset
for help on using the changeset viewer.