Changeset 17368
- Timestamp:
- 11/25/19 09:19:26 (5 years ago)
- Location:
- branches/2971_named_intervals
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis merged: 17305,17348,17350
- Property svn:mergeinfo changed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views merged: 17341
- Property svn:mergeinfo changed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs
r17208 r17368 93 93 var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray(); 94 94 95 // produce training and test values separately as they might overlap (e.g. for ensembles) 96 var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray(); 97 int j = 0; // idx for predictedValues array 98 foreach (var i in problemData.TrainingIndices) { 95 var predictedValues = Content.EstimatedValues.ToArray(); 96 foreach (var i in problemData.AllIndices) { 99 97 var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars); 100 98 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 101 AddErrors(run, predictedValuesTrain[j++], targetValue); 102 run.Results.Add(PartitionLabel, new StringValue("Training")); 103 run.Color = Color.Gold; 99 AddErrors(run, predictedValues[i], targetValue); 100 101 if (problemData.IsTrainingSample(i) && problemData.IsTestSample(i)) { 102 run.Results.Add(PartitionLabel, new StringValue("Training + Test")); 103 run.Color = Color.Orange; 104 } else if (problemData.IsTrainingSample(i)) { 105 run.Results.Add(PartitionLabel, new StringValue("Training")); 106 run.Color = Color.Gold; 107 } else if (problemData.IsTestSample(i)) { 108 run.Results.Add(PartitionLabel, new StringValue("Test")); 109 run.Color = Color.Red; 110 } else { 111 run.Results.Add(PartitionLabel, new StringValue("Additional Data")); 112 run.Color = Color.Black; 113 } 104 114 runs.Add(run); 105 115 } 106 var predictedValuesTest = Content.EstimatedTestValues.ToArray(); 107 j = 0; 108 foreach (var i in problemData.TestIndices) { 109 var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars); 110 var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i); 111 AddErrors(run, predictedValuesTest[j++], targetValue); 112 run.Results.Add(PartitionLabel, new StringValue("Test")); 113 run.Color = Color.Red; 114 runs.Add(run); 115 } 116 116 117 if (string.IsNullOrEmpty(selectedXAxis)) 117 118 selectedXAxis = "Index"; -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis/3.4 merged: 17305,17348,17350
- Property svn:mergeinfo changed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval.cs merged: 17348,17350
r17313 r17368 37 37 protected Interval(StorableConstructorFlag _) { } 38 38 39 /// <summary> 40 /// Creates an interval with given bounds, where lower bound must be smaller than 41 /// the upper bound. Floating point precision errors trough calculations are fixed by, 42 /// checking if the intervals are almost the same (E-12). If this is the case, the bounds 43 /// will be set to the bound closer to zero. 44 /// </summary> 45 /// <param name="lowerBound">Lower bound of the interval</param> 46 /// <param name="upperBound">Upper bound of the interval</param> 39 47 public Interval(double lowerBound, double upperBound) { 40 //TODO Handle floating point issues where lowerbound is bigger than upperbound in the nth decimal place 48 if (lowerBound.IsAlmost(upperBound)) { 49 //If the bounds go over zero 50 if (lowerBound <= 0 && upperBound >= 0) { 51 lowerBound = 0.0; 52 upperBound = 0.0; 53 //Interval is negative 54 } else if (upperBound < 0) { 55 lowerBound = upperBound; 56 //Interval is positive 57 } else { 58 upperBound = lowerBound; 59 } 60 } 61 41 62 if (lowerBound > upperBound) 42 63 throw new ArgumentException("lowerBound must be smaller than or equal to upperBound."); … … 98 119 } 99 120 121 /// <summary> 122 /// True if the interval is positive without zero 123 /// </summary> 124 public bool IsPositive { 125 get => LowerBound > 0.0; 126 } 127 128 /// <summary> 129 /// True if the interval is negative without zero 130 /// </summary> 131 public bool IsNegative { 132 get => UpperBound < 0.0; 133 } 134 100 135 public static Interval GetInterval(IEnumerable<double> values) { 101 136 if (values == null) throw new ArgumentNullException("values"); … … 166 201 } 167 202 168 // mkommend:Division by intervals containing 0 is implemented as defined in203 //Division by intervals containing 0 is implemented as defined in 169 204 //http://en.wikipedia.org/wiki/Interval_arithmetic 170 205 public static Interval Divide(Interval a, Interval b) { … … 209 244 public static Interval Tangens(Interval a) { 210 245 return Interval.Divide(Interval.Sine(a), Interval.Cosine(a)); 211 } 246 } 212 247 public static Interval HyperbolicTangent(Interval a) { 213 248 return new Interval(Math.Tanh(a.LowerBound), Math.Tanh(a.UpperBound)); … … 244 279 if (a.UpperBound <= 0) return new Interval(a.UpperBound * a.UpperBound, a.LowerBound * a.LowerBound); // interval is negative 245 280 else if (a.LowerBound >= 0) return new Interval(a.LowerBound * a.LowerBound, a.UpperBound * a.UpperBound); // interval is positive 246 else return new Interval(0, Math.Max(a.LowerBound *a.LowerBound, a.UpperBound*a.UpperBound)); // interval goes over zero281 else return new Interval(0, Math.Max(a.LowerBound * a.LowerBound, a.UpperBound * a.UpperBound)); // interval goes over zero 247 282 } 248 283 … … 273 308 var absLower = Math.Abs(a.LowerBound); 274 309 var absUpper = Math.Abs(a.UpperBound); 275 return new Interval(Math.Min(absLower, absUpper), Math.Max(absLower, absUpper)); 310 var min = Math.Min(absLower, absUpper); 311 var max = Math.Max(absLower, absUpper); 312 313 if (a.Contains(0.0)) { 314 min = 0.0; 315 } 316 317 return new Interval(min, max); 318 } 319 320 public static Interval AnalyticalQuotient(Interval a, Interval b) { 321 var dividend = a; 322 var divisor = Add(Square(b), new Interval(1.0, 1.0)); 323 divisor = SquareRoot(divisor); 324 325 var quotient = Divide(dividend, divisor); 326 return quotient; 276 327 } 277 328 #endregion - Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.