- Timestamp:
- 09/14/17 07:58:53 (7 years ago)
- Location:
- branches/MathNetNumerics-Exploration-2789
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/HeuristicLab.Algorithms.DataAnalysis.Experimental.csproj
r15352 r15362 120 120 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath> 121 121 </Reference> 122 <Reference Include="MathNet.Numerics, Version=3.20.0.0, Culture=neutral, processorArchitecture=MSIL"> 123 <HintPath>..\packages\MathNet.Numerics.3.20.0\lib\net40\MathNet.Numerics.dll</HintPath> 124 </Reference> 122 125 <Reference Include="System" /> 123 126 <Reference Include="System.Core" /> -
branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/Splines.cs
r15352 r15362 36 36 using HeuristicLab.Problems.DataAnalysis.Symbolic; 37 37 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression; 38 using MathNet.Numerics.Interpolation; 38 39 39 40 namespace HeuristicLab.Algorithms.DataAnalysis.Experimental { … … 59 60 var validTypes = new ItemSet<StringValue>( 60 61 new[] { 61 "Monotone", "Akima", "Catmull-Rom", "Cubic", "Linear" 62 "Monotone", "Akima", "Catmull-Rom", "Cubic", "Linear", 63 "Cubic - Natural (Math.NET)", 64 "Polynomial (Math.NET)", 65 "Rational (Math.NET)", 66 "LogLinear (Math.NET)", 67 "Common (Math.NET)", 62 68 }.Select(s => new StringValue(s))); 63 69 … … 83 89 switch (type) { 84 90 case "Monotone": 85 alglib.spline1dbuildmonotone(x, y, out c); break; 91 alglib.spline1dbuildmonotone(x, y, out c); 92 AddAlglibSplineResult(c, inputVars); 93 break; 86 94 case "Akima": 87 alglib.spline1dbuildakima(x, y, out c); break; 95 alglib.spline1dbuildakima(x, y, out c); AddAlglibSplineResult(c, inputVars); 96 break; 97 ; 88 98 case "Catmull-Rom": 89 alglib.spline1dbuildcatmullrom(x, y, out c); break; 99 alglib.spline1dbuildcatmullrom(x, y, out c); AddAlglibSplineResult(c, inputVars); 100 break; 101 90 102 case "Cubic": 91 alglib.spline1dbuildcubic(x, y, out c); break; 103 alglib.spline1dbuildcubic(x, y, out c); AddAlglibSplineResult(c, inputVars); 104 break; 105 92 106 case "Linear": 93 alglib.spline1dbuildlinear(x, y, out c); break; 94 107 alglib.spline1dbuildlinear(x, y, out c); AddAlglibSplineResult(c, inputVars); 108 break; 109 case "Cubic - Natural (Math.NET)": { 110 var spline = MathNet.Numerics.Interpolation.CubicSpline.InterpolateNatural(x, y); 111 AddMathNetSplineResult(spline, inputVars); 112 break; 113 } 114 case "Common (Math.NET)": { 115 var spline = MathNet.Numerics.Interpolate.Common(x, y); 116 AddMathNetSplineResult(spline, inputVars); 117 break; 118 } 119 case "LogLinear (Math.NET)": { 120 var spline = MathNet.Numerics.Interpolate.LogLinear(x, y); 121 AddMathNetSplineResult(spline, inputVars); 122 break; 123 } 124 case "Polynomial (Math.NET)": { 125 var spline = MathNet.Numerics.Interpolate.Polynomial(x, y); 126 AddMathNetSplineResult(spline, inputVars); 127 break; 128 } 129 case "Rational (Math.NET)": { 130 var spline = MathNet.Numerics.Interpolate.RationalWithoutPoles(x, y); 131 AddMathNetSplineResult(spline, inputVars); 132 break; 133 } 95 134 default: throw new NotSupportedException(); 96 135 } 97 136 98 Results.Add(new Result("Solution", new RegressionSolution(new Spline1dModel(c, Problem.ProblemData.TargetVariable, inputVars),99 (IRegressionProblemData)Problem.ProblemData.Clone())));100 137 } 138 } 139 140 private void AddAlglibSplineResult(alglib.spline1dinterpolant c, string[] inputVars) { 141 Results.Add(new Result("Solution", new RegressionSolution(new Spline1dModel(c, Problem.ProblemData.TargetVariable, inputVars), 142 (IRegressionProblemData)Problem.ProblemData.Clone()))); 143 144 } 145 private void AddMathNetSplineResult(IInterpolation c, string[] inputVars) { 146 Results.Add(new Result("Solution", new RegressionSolution(new MathNetSplineModel(c, Problem.ProblemData.TargetVariable, inputVars), 147 (IRegressionProblemData)Problem.ProblemData.Clone()))); 148 101 149 } 102 150 } … … 138 186 } 139 187 } 188 189 190 // UNFINISHED 191 public class MathNetSplineModel : NamedItem, IRegressionModel { 192 private IInterpolation interpolant; 193 194 public string TargetVariable { get; set; } 195 196 public IEnumerable<string> VariablesUsedForPrediction { get; private set; } 197 198 public event EventHandler TargetVariableChanged; 199 200 public MathNetSplineModel(MathNetSplineModel orig, Cloner cloner) : base(orig, cloner) { 201 this.TargetVariable = orig.TargetVariable; 202 this.VariablesUsedForPrediction = orig.VariablesUsedForPrediction.ToArray(); 203 this.interpolant = orig.interpolant; // TODO COPY! 204 } 205 public MathNetSplineModel(IInterpolation interpolant, string targetVar, string[] inputs) : base("SplineModel", "SplineModel") { 206 this.interpolant = interpolant; 207 this.TargetVariable = targetVar; 208 this.VariablesUsedForPrediction = inputs; 209 } 210 211 public override IDeepCloneable Clone(Cloner cloner) { 212 return new MathNetSplineModel(this, cloner); 213 } 214 215 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 216 return new RegressionSolution(this, (IRegressionProblemData)problemData.Clone()); 217 } 218 219 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 220 foreach (var x in dataset.GetDoubleValues(VariablesUsedForPrediction.First(), rows)) { 221 yield return interpolant.Interpolate(x); 222 } 223 } 224 } 140 225 } -
branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/packages.config
r15349 r15362 4 4 <package id="FSharp.Core" version="4.0.0.1" targetFramework="net46" /> 5 5 <package id="FSharp.Quotations.Evaluator" version="1.0.6" targetFramework="net46" /> 6 <package id="MathNet.Numerics" version="3.20.0" targetFramework="net46" /> 6 7 </packages> -
branches/MathNetNumerics-Exploration-2789/packages
- Property svn:ignore
-
old new 6 6 FSharp.Quotations.Evaluator.1.0.6 7 7 FSharp.Core.4.0.0.1 8 MathNet.Numerics.3.20.0
-
- Property svn:ignore
Note: See TracChangeset
for help on using the changeset viewer.