Changeset 17887 for branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis
- Timestamp:
- 03/12/21 14:00:36 (4 years ago)
- Location:
- branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4
- Files:
-
- 3 added
- 3 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r17768 r17887 190 190 <Compile Include="Implementation\Interval\Interval.cs" /> 191 191 <Compile Include="Implementation\Interval\IntervalCollection.cs" /> 192 <Compile Include="Implementation\Interval\ IntervalConstraint.cs" />193 <Compile Include="Implementation\Interval\ IntervalConstraintsParser.cs" />192 <Compile Include="Implementation\Interval\ShapeConstraint.cs" /> 193 <Compile Include="Implementation\Interval\ShapeConstraintsParser.cs" /> 194 194 <Compile Include="Implementation\Regression\ConfidenceBoundRegressionSolution.cs" /> 195 195 <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" /> 196 196 <Compile Include="Implementation\Regression\ConstantRegressionSolution.cs" /> 197 <Compile Include="Implementation\Regression\ShapeConstraints.cs" /> 197 198 <Compile Include="Implementation\Regression\RegressionEnsembleProblemData.cs" /> 198 199 <Compile Include="Implementation\Regression\RegressionEnsembleModel.cs"> … … 306 307 <Compile Include="Interfaces\IDataAnalysisModel.cs" /> 307 308 <Compile Include="Interfaces\IDataAnalysisProblem.cs" /> 308 <Compile Include="ProblemDataConstraint.cs" />309 309 <Compile Include="Properties\AssemblyInfo.cs" /> 310 310 </ItemGroup> -
branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs
r17770 r17887 25 25 using HEAL.Attic; 26 26 using HeuristicLab.Common; 27 using HeuristicLab.Core; 27 28 28 29 namespace HeuristicLab.Problems.DataAnalysis { … … 80 81 81 82 return false; 82 }83 84 public Tuple<Interval, Interval> Split() {85 var midpoint = Width / 2;86 var left = new Interval(LowerBound, LowerBound + midpoint - double.Epsilon);87 var right = new Interval(LowerBound + midpoint, UpperBound);88 return Tuple.Create(left, right);89 }90 91 //Interval Intersection92 public static Interval operator &(Interval lhs, Interval rhs) {93 return new Interval(Math.Max(lhs.LowerBound, rhs.LowerBound), Math.Min(lhs.UpperBound, rhs.UpperBound));94 }95 96 //Interval Union97 public static Interval operator |(Interval lhs, Interval rhs) {98 return new Interval(Math.Min(lhs.LowerBound, rhs.LowerBound), Math.Max(lhs.UpperBound, rhs.UpperBound));99 83 } 100 84 -
branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs
r17631 r17887 34 34 get => HeuristicLab.Common.Resources.VSImageLibrary.Object; 35 35 } 36 private IDictionary<string, Interval> intervals { get; } = new Dictionary<string, Interval>();37 36 38 [Storable(Name = "StorableIntervalInformation")] 37 //[Storable] 38 private IDictionary<string, Interval> intervals { get; set; } = new Dictionary<string, Interval>(); 39 40 [Storable(OldName = "StorableIntervalInformation")] 39 41 private KeyValuePair<string, double[]>[] StorableIntervalInformation { 42 set { 43 foreach (var varInt in value) 44 intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); 45 } 46 } 47 48 [Storable] 49 private object[] StorableIntervals { 40 50 get { 41 var l = new List<KeyValuePair<string, double[]>>(); 42 foreach (var varInt in intervals) 51 var names = intervals.Keys.ToArray(); 52 var lowerBounds = intervals.Values.Select(i => i.LowerBound).ToArray(); 53 var upperBounds = intervals.Values.Select(i => i.UpperBound).ToArray(); 43 54 44 l.Add(new KeyValuePair<string, double[]>(varInt.Key, 45 new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound })); 46 return l.ToArray(); 55 return new object[] { names, lowerBounds, upperBounds }; 47 56 } 48 57 49 58 set { 50 foreach (var varInt in value) 51 intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); 59 var names = (string[])value[0]; 60 var lowerBounds = (double[])value[1]; 61 var upperBounds = (double[])value[2]; 62 63 for (int i = 0; i < names.Length; i++) { 64 intervals.Add(names[i], new Interval(lowerBounds[i], upperBounds[i])); 65 } 52 66 } 53 67 } … … 80 94 public void SetInterval(string identifier, Interval interval) { 81 95 intervals[identifier] = interval; 96 RaiseChanged(); 82 97 } 83 98 84 99 public void AddInterval(string identifier, Interval interval) { 85 100 intervals.Add(identifier, interval); 101 RaiseChanged(); 86 102 } 87 103 88 104 public void DeleteInterval(string identifier) { 89 105 intervals.Remove(identifier); 106 RaiseChanged(); 90 107 } 91 108 … … 102 119 yield return Tuple.Create(variableInterval.Key, variableInterval.Value); 103 120 } 121 122 public event EventHandler Changed; 123 private void RaiseChanged() { 124 OnChanged(); 125 var handler = Changed; 126 if (handler != null) 127 handler(this, EventArgs.Empty); 128 } 129 130 protected virtual void OnChanged() { } 104 131 } 105 132 } -
branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r17607 r17887 94 94 problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>())); 95 95 problemData.Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, "", new IntervalCollection())); 96 problemData.Parameters.Add(new FixedValueParameter< ProblemDataConstraint>(IntervalConstraintsParameterName, "", new ProblemDataConstraint(problemData)));96 problemData.Parameters.Add(new FixedValueParameter<ShapeConstraints>(IntervalConstraintsParameterName, "", new ShapeConstraints())); 97 97 emptyProblemData = problemData; 98 98 } … … 109 109 } 110 110 111 public IFixedValueParameter< ProblemDataConstraint> IntervalConstraintsParameter =>112 (IFixedValueParameter< ProblemDataConstraint>) Parameters[IntervalConstraintsParameterName];113 114 public ProblemDataConstraintIntervalConstraints => IntervalConstraintsParameter.Value;111 public IFixedValueParameter<ShapeConstraints> IntervalConstraintsParameter => 112 (IFixedValueParameter<ShapeConstraints>) Parameters[IntervalConstraintsParameterName]; 113 114 public ShapeConstraints IntervalConstraints => IntervalConstraintsParameter.Value; 115 115 116 116 … … 148 148 149 149 if (!Parameters.ContainsKey(IntervalConstraintsParameterName)) { 150 Parameters.Add(new FixedValueParameter< ProblemDataConstraint>(IntervalConstraintsParameterName, new ProblemDataConstraint(this)));150 Parameters.Add(new FixedValueParameter<ShapeConstraints>(IntervalConstraintsParameterName, new ShapeConstraints())); 151 151 } 152 152 RegisterParameterEvents(); … … 173 173 } 174 174 175 public RegressionProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null) 175 public RegressionProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, 176 IEnumerable<ITransformation> transformations = null, 177 IntervalCollection variableRanges = null, 178 ShapeConstraints intervalConstraints = null) 176 179 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 177 180 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); 178 181 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First())); 179 var intervalCollection = CalculateDatasetIntervals(this.Dataset); 180 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, intervalCollection)); 181 Parameters.Add(new FixedValueParameter<ProblemDataConstraint>(IntervalConstraintsParameterName, new ProblemDataConstraint(this))); 182 if (variableRanges == null) { 183 variableRanges = CalculateDatasetIntervals(this.Dataset); 184 } 185 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges)); 186 if (intervalConstraints == null) { 187 intervalConstraints = new ShapeConstraints(); 188 } 189 Parameters.Add(new FixedValueParameter<ShapeConstraints>(IntervalConstraintsParameterName, intervalConstraints)); 182 190 RegisterParameterEvents(); 183 191 } … … 185 193 private static IntervalCollection CalculateDatasetIntervals(IDataset dataset) { 186 194 IntervalCollection intervalCollection = new IntervalCollection(); 187 foreach (var variable in dataset.DoubleVariables) { // intervals are only possible for double variables195 foreach (var variable in dataset.DoubleVariables) { // intervals are only possible for double variables 188 196 var variableInterval = Interval.GetInterval(dataset.GetDoubleValues(variable)); 189 197 intervalCollection.AddInterval(variable, variableInterval); -
branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs
r17607 r17887 30 30 string TargetVariable { get; set; } 31 31 32 IntervalCollection VariableRanges{ get; }33 ProblemDataConstraintIntervalConstraints { get; }32 IntervalCollection VariableRanges { get; } 33 ShapeConstraints IntervalConstraints { get; } 34 34 35 IEnumerable<double> TargetVariableValues 35 IEnumerable<double> TargetVariableValues { get; } 36 36 IEnumerable<double> TargetVariableTrainingValues { get; } 37 IEnumerable<double> TargetVariableTestValues 37 IEnumerable<double> TargetVariableTestValues { get; } 38 38 } 39 39 }
Note: See TracChangeset
for help on using the changeset viewer.