Changeset 11205 for branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
- Timestamp:
- 07/18/14 13:44:53 (10 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Text; 25 26 using HeuristicLab.Collections; 26 27 using HeuristicLab.Common; … … 37 38 protected const string TrainingPartitionParameterName = "TrainingPartition"; 38 39 protected const string TestPartitionParameterName = "TestPartition"; 40 protected const string TransformationsParameterName = "Transformations"; 39 41 40 42 #region parameter properites … … 50 52 public IFixedValueParameter<IntRange> TestPartitionParameter { 51 53 get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; } 54 } 55 public IFixedValueParameter<ReadOnlyItemList<ITransformation>> TransformationsParameter { 56 get { return (IFixedValueParameter<ReadOnlyItemList<ITransformation>>)Parameters[TransformationsParameterName]; } 52 57 } 53 58 #endregion … … 88 93 } 89 94 95 public IEnumerable<ITransformation> Transformations { 96 get { return TransformationsParameter.Value; } 97 } 98 90 99 public virtual bool IsTrainingSample(int index) { 91 100 return index >= 0 && index < Dataset.Rows && … … 110 119 [StorableHook(HookType.AfterDeserialization)] 111 120 private void AfterDeserialization() { 121 if (!Parameters.ContainsKey(TransformationsParameterName)) { 122 Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", new ItemList<ITransformation>().AsReadOnly())); 123 TransformationsParameter.Hidden = true; 124 } 112 125 RegisterEventHandlers(); 113 126 } 114 127 115 protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables ) {128 protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null) { 116 129 if (dataset == null) throw new ArgumentNullException("The dataset must not be null."); 117 130 if (allowedInputVariables == null) throw new ArgumentNullException("The allowedInputVariables must not be null."); … … 129 142 int testPartitionEnd = dataset.Rows; 130 143 144 var transformationsList = new ItemList<ITransformation>(transformations ?? Enumerable.Empty<ITransformation>()); 145 131 146 Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", dataset)); 132 147 Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly())); 133 148 Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd))); 134 149 Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd))); 150 Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly())); 151 152 TransformationsParameter.Hidden = true; 135 153 136 154 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; … … 143 161 TrainingPartition.ValueChanged += new EventHandler(Parameter_ValueChanged); 144 162 TestPartition.ValueChanged += new EventHandler(Parameter_ValueChanged); 163 TransformationsParameter.ValueChanged += new EventHandler(Parameter_ValueChanged); 145 164 } 146 165 … … 158 177 if (listeners != null) listeners(this, EventArgs.Empty); 159 178 } 179 180 protected virtual bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) { 181 errorMessage = string.Empty; 182 if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null."); 183 184 //check allowed input variables 185 StringBuilder message = new StringBuilder(); 186 var variables = new HashSet<string>(problemData.InputVariables.Select(x => x.Value)); 187 foreach (var item in AllowedInputVariables) { 188 if (!variables.Contains(item)) 189 message.AppendLine("Input variable '" + item + "' is not present in the new problem data."); 190 } 191 192 if (message.Length != 0) { 193 errorMessage = message.ToString(); 194 return false; 195 } 196 return true; 197 198 } 199 200 public virtual void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) { 201 DataAnalysisProblemData data = problemData as DataAnalysisProblemData; 202 if (data == null) throw new ArgumentException("The problem data is not a data analysis problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData"); 203 204 string errorMessage; 205 if (!data.IsProblemDataCompatible(this, out errorMessage)) { 206 throw new InvalidOperationException(errorMessage); 207 } 208 209 foreach (var inputVariable in InputVariables) { 210 var variable = data.InputVariables.FirstOrDefault(i => i.Value == inputVariable.Value); 211 InputVariables.SetItemCheckedState(inputVariable, variable != null && data.InputVariables.ItemChecked(variable)); 212 } 213 214 TrainingPartition.Start = TrainingPartition.End = 0; 215 TestPartition.Start = 0; 216 TestPartition.End = Dataset.Rows; 217 } 160 218 } 161 219 }
Note: See TracChangeset
for help on using the changeset viewer.