- Timestamp:
- 04/02/14 11:38:44 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r9456 r10695 291 291 } 292 292 293 public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable )294 : base(dataset, allowedInputVariables ) {293 public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null) 294 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 295 295 var validTargetVariableValues = CheckVariablesForPossibleTargetVariables(dataset).Select(x => new StringValue(x).AsReadOnly()).ToList(); 296 296 var target = validTargetVariableValues.Where(x => x.Value == targetVariable).DefaultIfEmpty(validTargetVariableValues.First()).First(); -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringProblemData.cs
r9456 r10695 21 21 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 86 87 } 87 88 88 public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables )89 : base(dataset, allowedInputVariables ) {89 public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null) 90 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 90 91 } 91 92 } -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r9456 r10695 37 37 protected const string TrainingPartitionParameterName = "TrainingPartition"; 38 38 protected const string TestPartitionParameterName = "TestPartition"; 39 protected const string TransformationsParameterName = "Transformations"; 39 40 40 41 #region parameter properites … … 50 51 public IFixedValueParameter<IntRange> TestPartitionParameter { 51 52 get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; } 53 } 54 public IFixedValueParameter<ReadOnlyItemCollection<ITransformation>> TransformationsParameter { 55 get { return (IFixedValueParameter<ReadOnlyItemCollection<ITransformation>>)Parameters[TransformationsParameterName]; } 52 56 } 53 57 #endregion … … 88 92 } 89 93 94 public IEnumerable<ITransformation> Transformations { 95 get { return TransformationsParameter.Value; } 96 } 97 90 98 public virtual bool IsTrainingSample(int index) { 91 99 return index >= 0 && index < Dataset.Rows && … … 111 119 private void AfterDeserialization() { 112 120 RegisterEventHandlers(); 121 122 if (!Parameters.ContainsKey(TransformationsParameterName)) { 123 Parameters.Add(new FixedValueParameter<ReadOnlyItemCollection<ITransformation>>(TransformationsParameterName, "", new ItemCollection<ITransformation>().AsReadOnly())); 124 } 113 125 } 114 126 115 protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables ) {127 protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations) { 116 128 if (dataset == null) throw new ArgumentNullException("The dataset must not be null."); 117 129 if (allowedInputVariables == null) throw new ArgumentNullException("The allowedInputVariables must not be null."); … … 119 131 if (allowedInputVariables.Except(dataset.DoubleVariables).Any()) 120 132 throw new ArgumentException("All allowed input variables must be present in the dataset and of type double."); 133 134 if (transformations == null) throw new ArgumentNullException("The transformations must not be null."); 121 135 122 136 var inputVariables = new CheckedItemList<StringValue>(dataset.DoubleVariables.Select(x => new StringValue(x))); … … 129 143 int testPartitionEnd = dataset.Rows; 130 144 145 var transformationsCollection = new ItemCollection<ITransformation>(transformations); 146 131 147 Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", dataset)); 132 148 Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly())); 133 149 Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd))); 134 150 Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd))); 151 Parameters.Add(new FixedValueParameter<ReadOnlyItemCollection<ITransformation>>(TransformationsParameterName, "", transformationsCollection.AsReadOnly())); 135 152 136 153 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r9456 r10695 129 129 } 130 130 131 public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable )132 : base(dataset, allowedInputVariables ) {131 public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null) 132 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 133 133 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); 134 134 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First())); -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs
r9456 r10695 39 39 IEnumerable<int> TestIndices { get; } 40 40 41 IEnumerable<ITransformation> Transformations { get; } 42 41 43 bool IsTrainingSample(int index); 42 44 bool IsTestSample(int index); -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/ITransformation.cs
r10694 r10695 20 20 #endregion 21 21 22 using System.Collections; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Core; 24 25 25 26 namespace HeuristicLab.Problems.DataAnalysis { 26 public interface ITransformation <T>: IParameterizedItem {27 public interface ITransformation : IParameterizedItem { 27 28 string Column { get; } 29 } 30 31 public interface ITransformation<T> : ITransformation { 28 32 IEnumerable<T> Apply(IEnumerable<T> data); 29 33 IEnumerable<T> InverseApply(IEnumerable<T> data);
Note: See TracChangeset
for help on using the changeset viewer.