Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17368


Ignore:
Timestamp:
11/25/19 09:19:26 (5 years ago)
Author:
chaider
Message:

#2971 Merged trunk into branch

Location:
branches/2971_named_intervals
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis

  • 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

  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs

    r17208 r17368  
    9393      var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();
    9494
    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) {
    9997        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    10098        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        }
    104114        runs.Add(run);
    105115      }
    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
    116117      if (string.IsNullOrEmpty(selectedXAxis))
    117118        selectedXAxis = "Index";
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4

  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs

    r17313 r17368  
    3737    protected Interval(StorableConstructorFlag _) { }
    3838
     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>
    3947    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
    4162      if (lowerBound > upperBound)
    4263        throw new ArgumentException("lowerBound must be smaller than or equal to upperBound.");
     
    98119    }
    99120
     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
    100135    public static Interval GetInterval(IEnumerable<double> values) {
    101136      if (values == null) throw new ArgumentNullException("values");
     
    166201    }
    167202
    168     //mkommend: Division by intervals containing 0 is implemented as defined in
     203    //Division by intervals containing 0 is implemented as defined in
    169204    //http://en.wikipedia.org/wiki/Interval_arithmetic
    170205    public static Interval Divide(Interval a, Interval b) {
     
    209244    public static Interval Tangens(Interval a) {
    210245      return Interval.Divide(Interval.Sine(a), Interval.Cosine(a));
    211     } 
     246    }
    212247    public static Interval HyperbolicTangent(Interval a) {
    213248      return new Interval(Math.Tanh(a.LowerBound), Math.Tanh(a.UpperBound));
     
    244279      if (a.UpperBound <= 0) return new Interval(a.UpperBound * a.UpperBound, a.LowerBound * a.LowerBound);     // interval is negative
    245280      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 zero
     281      else return new Interval(0, Math.Max(a.LowerBound * a.LowerBound, a.UpperBound * a.UpperBound)); // interval goes over zero
    247282    }
    248283
     
    273308      var absLower = Math.Abs(a.LowerBound);
    274309      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;
    276327    }
    277328    #endregion
Note: See TracChangeset for help on using the changeset viewer.