Changeset 4468 for trunk/sources/HeuristicLab.Problems.DataAnalysis
- Timestamp:
- 09/22/10 11:22:49 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblemData.cs
r4451 r4468 35 35 public class DataAnalysisProblemData : ParameterizedNamedItem, IStorableContent { 36 36 protected bool suppressEvents = false; 37 #region IStorableContent Members 38 public string Filename { get; set; } 39 #endregion 37 40 #region default data 38 41 // y = x^4 + x^3 + x^2 + x … … 87 90 get { return (IValueParameter<IntValue>)Parameters["TestSamplesEnd"]; } 88 91 } 92 public IValueParameter<PercentValue> ValidationPercentageParameter { 93 get { return (IValueParameter<PercentValue>)Parameters["ValidationPercentage"]; } 94 } 89 95 #endregion 90 96 91 97 #region properties 92 98 public Dataset Dataset { 93 get { return (Dataset)DatasetParameter.Value; }99 get { return DatasetParameter.Value; } 94 100 set { 95 101 if (value != Dataset) { … … 100 106 } 101 107 public StringValue TargetVariable { 102 get { return (StringValue)TargetVariableParameter.Value; }108 get { return TargetVariableParameter.Value; } 103 109 set { 104 110 if (value != TargetVariableParameter.Value) { … … 110 116 } 111 117 public ICheckedItemList<StringValue> InputVariables { 112 get { return (ICheckedItemList<StringValue>)InputVariablesParameter.Value; }118 get { return InputVariablesParameter.Value; } 113 119 set { 114 120 if (value != InputVariables) { … … 120 126 } 121 127 public IntValue TrainingSamplesStart { 122 get { return (IntValue)TrainingSamplesStartParameter.Value; }128 get { return TrainingSamplesStartParameter.Value; } 123 129 set { 124 130 if (value != TrainingSamplesStart) { … … 130 136 } 131 137 public IntValue TrainingSamplesEnd { 132 get { return (IntValue)TrainingSamplesEndParameter.Value; }138 get { return TrainingSamplesEndParameter.Value; } 133 139 set { 134 140 if (value != TrainingSamplesEnd) { … … 140 146 } 141 147 public IntValue TestSamplesStart { 142 get { return (IntValue)TestSamplesStartParameter.Value; }148 get { return TestSamplesStartParameter.Value; } 143 149 set { 144 150 if (value != TestSamplesStart) { … … 150 156 } 151 157 public IntValue TestSamplesEnd { 152 get { return (IntValue)TestSamplesEndParameter.Value; }158 get { return TestSamplesEndParameter.Value; } 153 159 set { 154 160 if (value != TestSamplesEnd) { … … 159 165 } 160 166 } 161 #endregion 162 163 #region IStorableContent Members 164 public string Filename { get; set; } 165 #endregion 167 public PercentValue ValidationPercentage { 168 get { return ValidationPercentageParameter.Value; } 169 set { 170 if (value != ValidationPercentage) { 171 if (value == null) throw new ArgumentNullException(); 172 if (value.Value < 0 || value.Value > 1) throw new ArgumentException("ValidationPercentage must be between 0 and 1."); 173 if (ValidationPercentage != null) DeregisterValueTypeEventHandlers(ValidationPercentage); 174 ValidationPercentageParameter.Value = value; 175 } 176 } 177 } 178 179 public IEnumerable<int> TrainingIndizes { 180 get { 181 return Enumerable.Range(TrainingSamplesStart.Value, TrainingSamplesEnd.Value - TrainingSamplesStart.Value) 182 .Where(i => i > 0 && i < Dataset.Rows && (i < TestSamplesStart.Value || TestSamplesEnd.Value <= i)); 183 } 184 } 185 public IEnumerable<int> TestIndizes { 186 get { 187 return Enumerable.Range(TestSamplesStart.Value, TestSamplesEnd.Value - TestSamplesStart.Value) 188 .Where(i => i > 0 && i < Dataset.Rows); 189 } 190 } 191 #endregion 192 166 193 167 194 public DataAnalysisProblemData() … … 180 207 Parameters.Add(new ValueParameter<IntValue>("TestSamplesStart", new IntValue(15))); 181 208 Parameters.Add(new ValueParameter<IntValue>("TestSamplesEnd", new IntValue(25))); 209 Parameters.Add(new ValueParameter<PercentValue>("ValidationPercentage", "The relative amount of the training samples that should be used as validation set.", new PercentValue(0.5))); 182 210 RegisterParameterEventHandlers(); 183 211 RegisterParameterValueEventHandlers(); … … 200 228 Parameters.Add(new ValueParameter<IntValue>("TestSamplesStart", new IntValue(testSamplesStart))); 201 229 Parameters.Add(new ValueParameter<IntValue>("TestSamplesEnd", new IntValue(testSamplesEnd))); 230 Parameters.Add(new ValueParameter<PercentValue>("ValidationPercentage", "The relative amount of the training samples that should be used as validation set.", new PercentValue(0.5))); 202 231 RegisterParameterEventHandlers(); 203 232 RegisterParameterValueEventHandlers(); … … 209 238 [StorableHook(HookType.AfterDeserialization)] 210 239 private void AfterDeserializationHook() { 240 if (!Parameters.ContainsKey("ValidationPercentage")) 241 Parameters.Add(new ValueParameter<PercentValue>("ValidationPercentage", "The relative amount of the training samples that should be used as validation set.", new PercentValue(0.5))); 242 211 243 RegisterParameterEventHandlers(); 212 244 RegisterParameterValueEventHandlers(); … … 230 262 TestSamplesStartParameter.ValueChanged += new EventHandler(TestSamplesStartParameter_ValueChanged); 231 263 TestSamplesEndParameter.ValueChanged += new EventHandler(TestSamplesEndParameter_ValueChanged); 264 ValidationPercentageParameter.ValueChanged += new EventHandler(ValidationPercentageParameter_ValueChanged); 232 265 } 233 266 … … 239 272 RegisterValueTypeEventHandlers(TestSamplesStart); 240 273 RegisterValueTypeEventHandlers(TestSamplesEnd); 274 RegisterValueTypeEventHandlers(ValidationPercentage); 241 275 } 242 276 … … 270 304 private void TestSamplesEndParameter_ValueChanged(object sender, EventArgs e) { 271 305 RegisterValueTypeEventHandlers(TestSamplesEnd); 306 OnProblemDataChanged(EventArgs.Empty); 307 } 308 private void ValidationPercentageParameter_ValueChanged(object sender, EventArgs e) { 309 RegisterValueTypeEventHandlers(ValidationPercentage); 272 310 OnProblemDataChanged(EventArgs.Empty); 273 311 }
Note: See TracChangeset
for help on using the changeset viewer.