Changeset 14310


Ignore:
Timestamp:
09/27/16 16:30:54 (5 years ago)
Author:
gkronber
Message:

changed interpreter and grammar to smooth ch and ins uptake using a compartement model

Location:
branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableSymbol.cs

    r13867 r14310  
    109109    }
    110110
    111     public CurvedChVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 10, double minBeta = 0.001, double maxBeta = 10)
     111    public CurvedChVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 0.999, double minBeta = 0.001, double maxBeta = 0.999)
    112112      : base(name, desc) {
    113113      this.minAlpha = minAlpha;
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableTreeNode.cs

    r13867 r14310  
    7777      base.ShakeLocalParameters(random, shakingFactor);
    7878      weight += NormalDistributedRandom.NextDouble(random, 0, 1.0 * shakingFactor);
    79       alpha += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
    80       beta += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
     79      alpha += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
     80      beta += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
    8181
    8282      alpha = Math.Min(Symbol.MaxAlpha, Math.Max(Symbol.MinAlpha, alpha));
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableSymbol.cs

    r13867 r14310  
    110110    }
    111111
    112     public CurvedInsVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 10, double minBeta = 0.001, double maxBeta = 10)
     112    public CurvedInsVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 0.999, double minBeta = 0.001, double maxBeta = 0.999)
    113113      : base(name, desc) {
    114114      this.minAlpha = minAlpha;
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableTreeNode.cs

    r13867 r14310  
    7878      base.ShakeLocalParameters(random, shakingFactor);
    7979      weight += NormalDistributedRandom.NextDouble(random, 0, 1.0 * shakingFactor);
    80       alpha += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
    81       beta += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
     80      alpha += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
     81      beta += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
    8282     
    8383      alpha = Math.Min(Symbol.MaxAlpha, Math.Max(Symbol.MinAlpha, alpha));
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Grammar.cs

    r13870 r14310  
    2424      var exprCh = new SimpleSymbol("ExprCh", string.Empty, 1, 1);
    2525
    26       var predGlucData = new PredictedGlucoseVariableSymbol();
     26      // var predGlucData = new PredictedGlucoseVariableSymbol();
    2727      var realGlucData = new RealGlucoseVariableSymbol();
    2828
     
    6060      var logIns = new SimpleSymbol("LogIns", "Log", 1, 1);
    6161      var curvedIns = new CurvedInsVariableSymbol("CurvedIns", "");
    62       var realInsVar = new RealInsulineVariableSymbol();
     62      // var realInsVar = new RealInsulineVariableSymbol();
    6363
    6464      var constSy = new Constant();
     
    6969      AddSymbol(exprIns);
    7070      AddSymbol(exprCh);
    71       AddSymbol(predGlucData);
     71      // AddSymbol(predGlucData);
    7272      AddSymbol(realGlucData);
    7373      AddSymbol(plusGluc);
     
    100100      AddSymbol(cosIns);
    101101      AddSymbol(logIns);
    102       AddSymbol(realInsVar);
     102      // AddSymbol(realInsVar);
    103103      AddSymbol(constSy);
    104104
     
    115115                    |realData(k-<idx2hOrMore>)
    116116      */
    117       var opGlucSet = new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc, expGluc, sinGluc, cosGluc, logGluc, predGlucData, realGlucData, constSy };
     117      var opGlucSet = new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc, expGluc, sinGluc, cosGluc, logGluc, /*predGlucData, */ realGlucData, constSy };
    118118      foreach (var opGluc in opGlucSet) {
    119119        AddAllowedChildSymbol(exprGluc, opGluc);
     
    192192
    193193      */
    194       var opInsSet = new Symbol[] { plusIns, minusIns, prodIns, divIns, expIns, sinIns, cosIns, logIns, realInsVar, curvedIns, constSy };
     194      var opInsSet = new Symbol[] { plusIns, minusIns, prodIns, divIns, expIns, sinIns, cosIns, logIns, /* realInsVar, */ curvedIns, constSy };
    195195      foreach (var opIns in opInsSet) {
    196196        AddAllowedChildSymbol(exprIns, opIns);
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction-3.3.csproj

    r13870 r14310  
    102102      <HintPath>..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
    103103    </Reference>
     104    <Reference Include="HeuristicLab.Algorithms.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     105      <SpecificVersion>False</SpecificVersion>
     106      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Algorithms.DataAnalysis-3.4.dll</HintPath>
     107    </Reference>
     108    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     109      <SpecificVersion>False</SpecificVersion>
     110      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     111    </Reference>
    104112    <Reference Include="HeuristicLab.Collections-3.3">
    105113      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     
    138146      <SpecificVersion>False</SpecificVersion>
    139147      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath>
     148    </Reference>
     149    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     150      <SpecificVersion>False</SpecificVersion>
     151      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath>
    140152    </Reference>
    141153    <Reference Include="HeuristicLab.Problems.Instances-3.3">
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Interpreter.cs

    r13870 r14310  
    22using System.Collections;
    33using System.Collections.Generic;
     4using System.Collections.ObjectModel;
    45using System.Collections.Specialized;
    56using System.Drawing.Design;
    67using System.Linq;
     8using HeuristicLab.Common;
    79using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    810using HeuristicLab.Problems.DataAnalysis;
     
    1517      public double[] realIns;
    1618      public double[] realCh;
    17       public double[] predGluc;
     19      public Dictionary<ISymbolicExpressionTreeNode, double[]> precalculatedValues;
    1820    }
    1921
     
    2527        realIns = dataset.GetDoubleValues("Insuline", rows).ToArray(),
    2628        realCh = dataset.GetDoubleValues("CH", rows).ToArray(),
     29        precalculatedValues = CreatePrecalculatedValues(model, dataset)
    2730      };
    28       data.predGluc = new double[data.realGluc.Length];
    29       Array.Copy(data.realGluc, data.predGluc, data.predGluc.Length);
    30       for (int k = 0; k < data.predGluc.Length; k++) {
     31      var predictions = new double[targetGluc.Length];
     32      var rowsEnumerator = rows.GetEnumerator();
     33      for (int k = 0; k < predictions.Length; k++, rowsEnumerator.MoveNext()) {
    3134        if (double.IsNaN(targetGluc[k])) {
    32           data.predGluc[k] = double.NaN;
     35          predictions[k] = double.NaN;
    3336        } else {
    34           var rawPred = InterpretRec(model, data, k);
    35           data.predGluc[k] = Math.Max(0, Math.Min(400, rawPred)); // limit output values of the model to 0 ... 400
    36         }
    37       }
    38       return data.predGluc;
     37          var rawPred = InterpretRec(model, data, rowsEnumerator.Current);
     38          predictions[k] = rawPred;
     39        }
     40      }
     41      return predictions;
     42    }
     43
     44    private static Dictionary<ISymbolicExpressionTreeNode, double[]> CreatePrecalculatedValues(ISymbolicExpressionTreeNode root, IDataset dataset) {
     45      var dict = new Dictionary<ISymbolicExpressionTreeNode, double[]>();
     46      // here we integrate ins or ch inputs over the whole day to generate smoothed ins/ch values with the same number of rows
     47      // the integrated values are reset to zero whenever a new evluation period starts
     48      foreach (var node in root.IterateNodesPrefix()) {
     49        var curvedInsNode = node as CurvedInsVariableTreeNode;
     50        var curvedChNode = node as CurvedChVariableTreeNode;
     51        if (curvedInsNode != null) {
     52          dict.Add(curvedInsNode, Integrate(curvedInsNode, dataset));
     53        } else if (curvedChNode != null) {
     54          dict.Add(curvedChNode, Integrate(curvedChNode, dataset));
     55        }
     56      }
     57      return dict;
     58    }
     59
     60    private static double[] Integrate(CurvedInsVariableTreeNode node, IDataset dataset) {
     61      // d Q1 / dt = ins(t) - alpha * Q1(t)
     62      // d Q2 / dt = alpha * (Q1(t) - Q2(t))
     63      // S = Q1(t) + Q2(t)
     64      var alpha = node.Alpha;
     65
     66      var ins = dataset.GetReadOnlyDoubleValues("Insuline");
     67      var time = dataset.GetReadOnlyDoubleValues("HourMin").ToArray();
     68
     69      // TODO reset for new time intervals
     70
     71      double q1, q2, q1_prev, q2_prev;
     72      // starting values: zeros
     73      q1 = q2 = q1_prev = q2_prev = 0;
     74      double[] s = new double[dataset.Rows];
     75
     76      for (int t = 1; t < dataset.Rows; t++) {
     77        if (IsStartOfNewPeriod(time, t)) {
     78          q1 = q2 = q1_prev = q2_prev = 0;
     79        }
     80        q1 = q1_prev + ins[t] - alpha * q1_prev;
     81        q2 = q2_prev + alpha * (q1_prev - q2_prev);
     82        s[t] = q1 + q2;
     83        q1_prev = q1;
     84        q2_prev = q2;
     85
     86      }
     87      return s;
     88    }
     89
     90    private static bool IsStartOfNewPeriod(double[] time, int t) {
     91      return t == 0 ||
     92             (time[t].IsAlmost(2005) && !time[t - 1].IsAlmost(2000));
     93    }
     94
     95
     96    private static double[] Integrate(CurvedChVariableTreeNode node, IDataset dataset) {
     97      // d Q1 / dt = ins(t) - alpha * Q1(t)
     98      // d Q2 / dt = alpha * (Q1(t) - Q2(t))
     99      // S = Q1(t) + Q2(t)
     100      var alpha = node.Alpha;
     101
     102      var ch = dataset.GetReadOnlyDoubleValues("CH");
     103      var time = dataset.GetReadOnlyDoubleValues("HourMin").ToArray();
     104
     105      // TODO reset for new time intervals
     106
     107      double q1, q2, q1_prev, q2_prev;
     108      // starting values: zeros
     109      q1 = q2 = q1_prev = q2_prev = 0;
     110      double[] s = new double[dataset.Rows];
     111
     112      for (int t = 1; t < dataset.Rows; t++) {
     113        if (IsStartOfNewPeriod(time, t)) {
     114          q1 = q2 = q1_prev = q2_prev = 0;
     115        }
     116        q1 = q1_prev + ch[t] - alpha * q1_prev;
     117        q2 = q2_prev + alpha * (q1_prev - q2_prev);
     118        s[t] = q1 + q2;
     119        q1_prev = q1;
     120        q2_prev = q2;
     121
     122      }
     123      return s;
    39124    }
    40125
     
    102187        }
    103188      } else if (node.Symbol is PredictedGlucoseVariableSymbol) {
    104         var n = (PredictedGlucoseVariableTreeNode)node;
    105         return n.Weight * data.predGluc[k + n.RowOffset];
     189        throw new NotSupportedException();
    106190      } else if (node.Symbol is RealGlucoseVariableSymbol) {
    107191        var n = (RealGlucoseVariableTreeNode)node;
    108         return n.Weight * data.realGluc[k + n.RowOffset];
     192        if (k + n.RowOffset < 0 || k + n.RowOffset >= data.realGluc.Length) return double.NaN;
     193        return data.realGluc[k + n.RowOffset];
    109194      } else if (node.Symbol is CurvedChVariableSymbol) {
    110         var n = (CurvedChVariableTreeNode)node;
    111         double prevVal;
    112         int prevValDistance;
    113         GetPrevDataAndDistance(data.realCh, k, out prevVal, out prevValDistance, maxDistance: 48);
    114         return n.Weight * prevVal * Beta(prevValDistance / 48.0, n.Alpha, n.Beta);
     195        return data.precalculatedValues[node][k];
    115196      } else if (node.Symbol is RealInsulineVariableSymbol) {
    116         var n = (RealInsulineVariableTreeNode)node;
    117         return n.Weight * data.realIns[k + n.RowOffset];
     197        throw new NotSupportedException();
    118198      } else if (node.Symbol is CurvedInsVariableSymbol) {
    119         var n = (CurvedInsVariableTreeNode)node;
    120         double maxVal;
    121         int maxValDistance;
    122         var sum = GetSumOfValues(48, k, data.realIns);
    123 
    124         GetMaxValueAndDistance(data.realIns, k, out maxVal, out maxValDistance, maxDistance: 48);
    125         return n.Weight * (sum - maxVal) * maxVal * Beta(maxValDistance / 48.0, n.Alpha, n.Beta);
     199        return data.precalculatedValues[node][k];
    126200      } else if (node.Symbol is Constant) {
    127201        var n = (ConstantTreeNode)node;
     
    135209      return 1.0 / alglib.beta(alpha, beta) * Math.Pow(x, alpha - 1) * Math.Pow(1 - x, beta - 1);
    136210    }
    137 
    138     private static void GetPrevDataAndDistance(double[] vals, int k, out double val, out int dist, int maxDistance = 48, double threshold = 0.0) {
    139       // look backward from the current idx k and find the first value above the threshold
    140       for (int i = k; i >= 0 && i >= (k - maxDistance); i--) {
    141         if (vals[i] > threshold) {
    142           val = vals[i];
    143           dist = k - i;
    144           return;
    145         }
    146       }
    147       val = 0;
    148       dist = maxDistance;
    149     }
    150 
    151     private static double GetSumOfValues(int windowSize, int k, double[] vals) {
    152       var sum = 0.0;
    153       for (int i = k; i >= 0 && i >= k - windowSize; i--)
    154         sum += vals[i];
    155       return sum;
    156     }
    157 
    158     private static void GetMaxValueAndDistance(double[] vals, int k, out double maxVal, out int dist, int maxDistance = 48) {
    159       // look backward from the current idx k and find the max value and it's distance
    160       maxVal = vals[k];
    161       dist = 0;
    162       for (int i = k; i >= 0 && i >= (k - maxDistance); i--) {
    163         if (vals[i] > maxVal) {
    164           maxVal = vals[i];
    165           dist = k - i;
    166         }
    167       }
    168     }
    169211  }
    170212}
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Model.cs

    r13865 r14310  
    1111using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    1212using HeuristicLab.Problems.DataAnalysis;
     13using Microsoft.Win32.SafeHandles;
    1314
    1415namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction {
     
    1617  [Item("Model", "")]
    1718  public sealed class Model : NamedItem, IRegressionModel {
     19    [Storable]
    1820    private readonly IRegressionProblemData problemData;
     21    [Storable]
    1922    private readonly ISymbolicExpressionTree tree;
     23    [Storable]
     24    private string targetVariable;
     25    [Storable]
     26    private string[] variablesUsedForPrediction;
    2027
    2128    private Model(Model original, Cloner cloner) {
    2229      this.problemData = cloner.Clone(original.problemData);
    2330      this.tree = cloner.Clone(original.tree);
     31      this.variablesUsedForPrediction = original.variablesUsedForPrediction;
     32      this.targetVariable = original.targetVariable;
    2433    }
    2534
    26     public Model(IRegressionProblemData problemData, ISymbolicExpressionTree tree) {
     35    public Model(IRegressionProblemData problemData, ISymbolicExpressionTree tree, string targetVariable, string[] variablesUsedForPrediction) {
    2736      this.problemData = problemData;
    2837      this.tree = tree;
     38      this.variablesUsedForPrediction = variablesUsedForPrediction;
     39      this.targetVariable = targetVariable;
    2940    }
    3041
     
    4051      return new Solution(this, problemData);
    4152    }
     53
     54
     55    public string TargetVariable {
     56      get {
     57        return targetVariable;
     58      }
     59      set {
     60        throw new NotSupportedException();
     61      }
     62    }
     63
     64    public event EventHandler TargetVariableChanged;
     65
     66
     67    public IEnumerable<string> VariablesUsedForPrediction {
     68      get { return variablesUsedForPrediction; }
     69    }
    4270  }
    4371}
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Problem.cs

    r13865 r14310  
    2121
    2222using System;
     23using System.Collections;
    2324using System.Collections.Generic;
    2425using System.Linq;
     26using HeuristicLab.Analysis;
    2527using HeuristicLab.Common;
    2628using HeuristicLab.Core;
     
    6264
    6365    public override bool Maximization {
    64       get { return false; }
     66      get { return true; }
    6567    }
    6668
     
    98100      var rows = problemData.TrainingIndices.ToArray();
    99101      var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    100       var predicted = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0), problemData.Dataset, rows); 
    101 
     102      var predicted0 = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(0), problemData.Dataset, rows);
     103      var predicted1 = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(1), problemData.Dataset, rows);
     104      var predicted2 = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(2), problemData.Dataset, rows);
     105
     106      var pred0_rsq = Rsq(predicted0, target);
     107      var pred1_rsq = Rsq(predicted1, target);
     108      var pred2_rsq = Rsq(predicted2, target);
     109      return pred0_rsq + pred1_rsq + pred2_rsq;
     110    }
     111
     112    private double Rsq(IEnumerable<double> predicted, IEnumerable<double> target) {
    102113      // only take predictions for which the target is not NaN
    103114      var selectedTuples = target.Zip(predicted, Tuple.Create).Where(t => !double.IsNaN(t.Item1)).ToArray();
     
    106117
    107118      OnlineCalculatorError errorState;
    108       var mse = OnlineMeanSquaredErrorCalculator.Calculate(target, predicted, out errorState);
    109       if (errorState != OnlineCalculatorError.None) mse = 1E6;
    110       return mse;
    111     }
    112 
    113     public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results, IRandom random) {
     119      var r = OnlinePearsonsRCalculator.Calculate(target, predicted, out errorState);
     120      if (errorState != OnlineCalculatorError.None) r = 0;
     121      return r * r;
     122    }
     123
     124    public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results,
     125      IRandom random) {
    114126      base.Analyze(trees, qualities, results, random);
    115127
    116128      if (!results.ContainsKey("Solution")) {
    117129        results.Add(new Result("Solution", typeof(IRegressionSolution)));
     130      }
     131      if (!results.ContainsKey("Terms")) {
     132        results.Add(new Result("Terms", typeof(DataTable)));
    118133      }
    119134
     
    121136      var bestQuality = qualities.First();
    122137      for (int i = 1; i < trees.Length; i++) {
    123         if (qualities[i] < bestQuality) {
     138        if (qualities[i] > bestQuality) {
    124139          bestQuality = qualities[i];
    125140          bestTree = trees[i];
     
    127142      }
    128143
     144
    129145      var clonedProblemData = (IRegressionProblemData)ProblemData.Clone();
    130       var model = new Model(clonedProblemData, (ISymbolicExpressionTree)bestTree.Clone());
    131       results["Solution"].Value = model.CreateRegressionSolution(clonedProblemData);
     146      var rows = clonedProblemData.TrainingIndices.ToArray();
     147      var target = clonedProblemData.Dataset.GetDoubleValues(clonedProblemData.TargetVariable, rows).ToArray();
     148      var predicted0 =
     149        Interpreter.Apply(bestTree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(0), clonedProblemData.Dataset, rows)
     150          .ToArray();
     151      var predicted1 =
     152        Interpreter.Apply(bestTree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(1), clonedProblemData.Dataset, rows)
     153          .ToArray();
     154      var predicted2 =
     155        Interpreter.Apply(bestTree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(2), clonedProblemData.Dataset, rows)
     156          .ToArray();
     157
     158      var termsTable = new HeuristicLab.Analysis.DataTable("Terms");
     159      var r0 = new DataRow("GlucTerm", "GlucTerm", predicted0);
     160      var r1 = new DataRow("InsTerm", "InsTerm", predicted1);
     161      r1.VisualProperties.SecondYAxis = true;
     162      var r2 = new DataRow("ChTerm", "ChTerm", predicted2);
     163      r2.VisualProperties.SecondYAxis = true;
     164      var r3 = new DataRow("Target", "Target", target);
     165      termsTable.Rows.Add(r0);
     166      termsTable.Rows.Add(r1);
     167      termsTable.Rows.Add(r2);
     168      termsTable.Rows.Add(r3);
     169      results["Terms"].Value = termsTable;
     170
     171
     172      var filteredPredicted0 = rows.Where(r => !double.IsNaN(target[r])).Select(r => predicted0[r]).ToArray();
     173      var filteredPredicted1 = rows.Where(r => !double.IsNaN(target[r])).Select(r => predicted1[r]).ToArray();
     174      var filteredPredicted2 = rows.Where(r => !double.IsNaN(target[r])).Select(r => predicted2[r]).ToArray();
     175      var filteredTarget = target.Where(t => !double.IsNaN(t)).ToArray();
     176
     177
     178      var ds = new ModifiableDataset(new string[] { "pred0", "pred1", "pred2", "target" },
     179        new List<IList>
     180        {
     181          filteredPredicted0.ToList(),
     182          filteredPredicted1.ToList(),
     183          filteredPredicted2.ToList(),
     184          filteredTarget.ToList()
     185        });
     186      var lrProbData = new RegressionProblemData(ds, new string[] { "pred0", "pred1", "pred2" }, "target");
     187      lrProbData.TrainingPartition.Start = clonedProblemData.TrainingPartition.Start;
     188      lrProbData.TrainingPartition.End = clonedProblemData.TrainingPartition.End;
     189      lrProbData.TestPartition.Start = clonedProblemData.TestPartition.Start;
     190      lrProbData.TestPartition.End = clonedProblemData.TestPartition.End;
     191
     192      try {
     193        double rmsError, cvRmsError;
     194        var lrSolution = HeuristicLab.Algorithms.DataAnalysis.LinearRegression.CreateLinearRegressionSolution(
     195          lrProbData, out rmsError, out cvRmsError);
     196        results["Solution"].Value = lrSolution;
     197      } catch (Exception) {
     198        // ignore
     199      }
    132200    }
    133201
  • branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/RealGlucoseVariableSymbol.cs

    r13865 r14310  
    8888    public RealGlucoseVariableSymbol()
    8989      : base(Name, string.Empty) {
    90       minRowOffset = -48;
     90      minRowOffset = -24;
    9191      maxRowOffset = -24;
    9292    }
Note: See TracChangeset for help on using the changeset viewer.