Changeset 11114 for trunk/sources/HeuristicLab.Problems.DataAnalysis
- Timestamp:
- 07/07/14 15:33:56 (10 years ago)
- Location:
- trunk/sources
- Files:
-
- 18 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs
r10406 r11114 170 170 yield return value; 171 171 } 172 173 public IEnumerable<string> GetStringValues(string variableName) { 174 IList list; 175 if (!variableValues.TryGetValue(variableName, out list)) 176 throw new ArgumentException("The variable " + variableName + " does not exist in the dataset."); 177 List<string> values = list as List<string>; 178 if (values == null) throw new ArgumentException("The variable " + variableName + " is not a string variable."); 179 180 //mkommend yield return used to enable lazy evaluation 181 foreach (string value in values) 182 yield return value; 183 } 184 185 public IEnumerable<DateTime> GetDateTimeValues(string variableName) { 186 IList list; 187 if (!variableValues.TryGetValue(variableName, out list)) 188 throw new ArgumentException("The variable " + variableName + " does not exist in the dataset."); 189 List<DateTime> values = list as List<DateTime>; 190 if (values == null) throw new ArgumentException("The variable " + variableName + " is not a datetime variable."); 191 192 //mkommend yield return used to enable lazy evaluation 193 foreach (DateTime value in values) 194 yield return value; 195 } 196 172 197 public ReadOnlyCollection<double> GetReadOnlyDoubleValues(string variableName) { 173 198 IList list; … … 194 219 195 220 return rows.Select(index => values[index]); 221 } 222 223 public bool IsType<T>(string variableName) { 224 return variableValues[variableName] is IList<T>; 196 225 } 197 226 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r9973 r11114 141 141 <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolution.cs" /> 142 142 <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolutionBase.cs" /> 143 <Compile Include="Implementation\Transformations\CopyColumnTransformation.cs" /> 144 <Compile Include="Implementation\Transformations\ExponentialTransformation.cs" /> 145 <Compile Include="Implementation\Transformations\LinearTransformation.cs" /> 146 <Compile Include="Implementation\Transformations\LogarithmicTransformation.cs" /> 147 <Compile Include="Implementation\Transformations\PowerTransformation.cs" /> 148 <Compile Include="Implementation\Transformations\ReciprocalTransformation.cs" /> 149 <Compile Include="Implementation\Transformations\ShiftStandardDistributionTransformation.cs" /> 150 <Compile Include="Implementation\Transformations\ShiftToRangeTransformation.cs" /> 151 <Compile Include="Implementation\Transformations\Transformation.cs" /> 143 152 <Compile Include="Interfaces\Classification\IClassificationEnsembleModel.cs"> 144 153 <SubType>Code</SubType> … … 150 159 <Compile Include="Interfaces\IDataAnalysisSolutionExporter.cs" /> 151 160 <Compile Include="Interfaces\IDependencyCalculator.cs" /> 161 <Compile Include="Interfaces\IModelBacktransformator.cs" /> 162 <Compile Include="Interfaces\ITransformation.cs" /> 163 <Compile Include="Interfaces\ITransformationMapper.cs" /> 152 164 <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs"> 153 165 <SubType>Code</SubType> -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r10540 r11114 300 300 } 301 301 302 public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable )303 : base(dataset, allowedInputVariables ) {302 public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null) 303 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 304 304 var validTargetVariableValues = CheckVariablesForPossibleTargetVariables(dataset).Select(x => new StringValue(x).AsReadOnly()).ToList(); 305 305 var target = validTargetVariableValues.Where(x => x.Value == targetVariable).DefaultIfEmpty(validTargetVariableValues.First()).First(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringProblemData.cs
r9456 r11114 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 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r10540 r11114 38 38 protected const string TrainingPartitionParameterName = "TrainingPartition"; 39 39 protected const string TestPartitionParameterName = "TestPartition"; 40 protected const string TransformationsParameterName = "Transformations"; 40 41 41 42 #region parameter properites … … 51 52 public IFixedValueParameter<IntRange> TestPartitionParameter { 52 53 get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; } 54 } 55 public IFixedValueParameter<ReadOnlyItemList<ITransformation>> TransformationsParameter { 56 get { return (IFixedValueParameter<ReadOnlyItemList<ITransformation>>)Parameters[TransformationsParameterName]; } 53 57 } 54 58 #endregion … … 89 93 } 90 94 95 public IEnumerable<ITransformation> Transformations { 96 get { return TransformationsParameter.Value; } 97 } 98 91 99 public virtual bool IsTrainingSample(int index) { 92 100 return index >= 0 && index < Dataset.Rows && … … 111 119 [StorableHook(HookType.AfterDeserialization)] 112 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 } 113 125 RegisterEventHandlers(); 114 126 } 115 127 116 protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables ) {128 protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations) { 117 129 if (dataset == null) throw new ArgumentNullException("The dataset must not be null."); 118 130 if (allowedInputVariables == null) throw new ArgumentNullException("The allowedInputVariables must not be null."); … … 120 132 if (allowedInputVariables.Except(dataset.DoubleVariables).Any()) 121 133 throw new ArgumentException("All allowed input variables must be present in the dataset and of type double."); 134 135 if (transformations == null) throw new ArgumentNullException("The transformations must not be null."); 122 136 123 137 var inputVariables = new CheckedItemList<StringValue>(dataset.DoubleVariables.Select(x => new StringValue(x))); … … 130 144 int testPartitionEnd = dataset.Rows; 131 145 146 var transformationsList = new ItemList<ITransformation>(transformations); 147 132 148 Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", dataset)); 133 149 Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly())); 134 150 Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd))); 135 151 Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd))); 152 Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly())); 153 154 TransformationsParameter.Hidden = true; 136 155 137 156 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; … … 144 163 TrainingPartition.ValueChanged += new EventHandler(Parameter_ValueChanged); 145 164 TestPartition.ValueChanged += new EventHandler(Parameter_ValueChanged); 165 TransformationsParameter.ValueChanged += new EventHandler(Parameter_ValueChanged); 146 166 } 147 167 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r10540 r11114 137 137 } 138 138 139 public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable )140 : base(dataset, allowedInputVariables ) {139 public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null) 140 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 141 141 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); 142 142 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First())); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs
r11031 r11114 1582 1582 TrainingPartition.Start = 50; 1583 1583 } 1584 public TimeSeriesPrognosisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable )1585 : base(dataset, allowedInputVariables, targetVariable ) {1584 public TimeSeriesPrognosisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null) 1585 : base(dataset, allowedInputVariables, targetVariable, transformations ?? Enumerable.Empty<ITransformation>()) { 1586 1586 Parameters.Add(new FixedValueParameter<IntValue>(TrainingHorizonParameterName, "Specifies the horizon (how far the prognosis reaches in the future) for each training sample.", new IntValue(1))); 1587 1587 Parameters.Add(new FixedValueParameter<IntValue>(TestHorizonParameterName, "Specifies the horizon (how far the prognosis reaches in the future) for each test sample.", new IntValue(1))); … … 1643 1643 1644 1644 var trainingDataStart = TrainingIndices.First(); 1645 1645 1646 1646 base.AdjustProblemDataProperties(problemData); 1647 1647 1648 1648 TestPartition.Start = trainingDataStart; 1649 1649 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ExponentialTransformation.cs
r11068 r11114 29 29 [StorableConstructor] 30 30 protected ExponentialTransformation(bool deserializing) : base(deserializing) { } 31 protected ExponentialTransformation(Transformation<double> original, Cloner cloner) 31 32 protected ExponentialTransformation(ExponentialTransformation original, Cloner cloner) 32 33 : base(original, cloner) { 33 34 } 35 34 36 public ExponentialTransformation(IEnumerable<string> allowedColumns) 35 37 : base(allowedColumns) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs
r11068 r11114 66 66 [StorableConstructor] 67 67 protected LinearTransformation(bool deserializing) : base(deserializing) { } 68 protected LinearTransformation( Transformation<double>original, Cloner cloner)68 protected LinearTransformation(LinearTransformation original, Cloner cloner) 69 69 : base(original, cloner) { 70 70 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmicTransformation.cs
r11068 r11114 30 30 [StorableConstructor] 31 31 protected LogarithmicTransformation(bool deserializing) : base(deserializing) { } 32 protected LogarithmicTransformation( Transformation<double>original, Cloner cloner)32 protected LogarithmicTransformation(LogarithmicTransformation original, Cloner cloner) 33 33 : base(original, cloner) { 34 34 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/PowerTransformation.cs
r11068 r11114 29 29 [StorableConstructor] 30 30 protected PowerTransformation(bool deserializing) : base(deserializing) { } 31 protected PowerTransformation( Transformation<double>original, Cloner cloner)31 protected PowerTransformation(PowerTransformation original, Cloner cloner) 32 32 : base(original, cloner) { 33 33 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ReciprocalTransformation.cs
r11068 r11114 19 19 [StorableConstructor] 20 20 protected ReciprocalTransformation(bool deserializing) : base(deserializing) { } 21 protected ReciprocalTransformation( Transformation<double>original, Cloner cloner)21 protected ReciprocalTransformation(ReciprocalTransformation original, Cloner cloner) 22 22 : base(original, cloner) { 23 23 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftStandardDistributionTransformation.cs
r11068 r11114 52 52 [StorableConstructor] 53 53 protected ShiftStandardDistributionTransformation(bool deserializing) : base(deserializing) { } 54 protected ShiftStandardDistributionTransformation( Transformation<double>original, Cloner cloner)54 protected ShiftStandardDistributionTransformation(ShiftStandardDistributionTransformation original, Cloner cloner) 55 55 : base(original, cloner) { 56 56 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftToRangeTransformation.cs
r11068 r11114 29 29 [StorableConstructor] 30 30 protected ShiftToRangeTransformation(bool deserializing) : base(deserializing) { } 31 protected ShiftToRangeTransformation( Transformation<double>original, Cloner cloner)31 protected ShiftToRangeTransformation(ShiftToRangeTransformation original, Cloner cloner) 32 32 : base(original, cloner) { 33 33 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs
r10540 r11114 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); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Plugin.cs.frame
r10037 r11114 37 37 [PluginDependency("HeuristicLab.Parameters", "3.3")] 38 38 [PluginDependency("HeuristicLab.Persistence", "3.3")] 39 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 39 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 40 40 public class HeuristicLabProblemsDataAnalysisPlugin : PluginBase { 41 41 }
Note: See TracChangeset
for help on using the changeset viewer.