Changeset 10553 for branches/ClassificationModelComparison
- Timestamp:
- 03/05/14 17:30:38 (11 years ago)
- Location:
- branches/ClassificationModelComparison
- Files:
-
- 1 deleted
- 94 edited
- 13 copied
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs ¶
r8970 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 266 266 } 267 267 268 private bool startPending;269 268 public void Start() { 270 269 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused)) 271 270 throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState)); 272 271 273 if (Algorithm != null && !startPending) { 274 startPending = true; 272 if (Algorithm != null) { 275 273 //create cloned algorithms 276 274 if (clonedAlgorithms.Count == 0) { … … 335 333 if (!pausePending) { 336 334 pausePending = true; 337 if (!startPending)PauseAllClonedAlgorithms();335 PauseAllClonedAlgorithms(); 338 336 } 339 337 } … … 352 350 if (!stopPending) { 353 351 stopPending = true; 354 if (!startPending)StopAllClonedAlgorithms();352 StopAllClonedAlgorithms(); 355 353 } 356 354 } … … 389 387 390 388 private void AggregateResultValues(IDictionary<string, IItem> results) { 391 Dictionary<string, List<double>> resultValues = new Dictionary<string, List<double>>();392 389 IEnumerable<IRun> runs = clonedAlgorithms.Select(alg => alg.Runs.FirstOrDefault()).Where(run => run != null); 393 390 IEnumerable<KeyValuePair<string, IItem>> resultCollections = runs.Where(x => x != null).SelectMany(x => x.Results).ToList(); … … 552 549 } 553 550 if (problem != null) problem.Reset -= new EventHandler(Problem_Reset); 554 if (Problem != null) Problem.Reset += new EventHandler(Problem_Reset);555 551 problem = (IDataAnalysisProblem)algorithm.Problem; 552 if (problem != null) problem.Reset += new EventHandler(Problem_Reset); 556 553 OnProblemChanged(); 557 554 } … … 653 650 654 651 private readonly object locker = new object(); 652 private readonly object resultLocker = new object(); 655 653 private void ClonedAlgorithm_Started(object sender, EventArgs e) { 656 lock (locker) {657 IAlgorithm algorithm = sender as IAlgorithm;654 IAlgorithm algorithm = sender as IAlgorithm; 655 lock (resultLocker) { 658 656 if (algorithm != null && !results.ContainsKey(algorithm.Name)) 659 657 results.Add(new Result(algorithm.Name, "Contains results for the specific fold.", algorithm.Results)); 660 661 if (startPending) {662 int startedAlgorithms = clonedAlgorithms.Count(alg => alg.ExecutionState == ExecutionState.Started);663 if (startedAlgorithms == NumberOfWorkers.Value ||664 clonedAlgorithms.All(alg => alg.ExecutionState != ExecutionState.Prepared))665 startPending = false;666 667 if (pausePending) PauseAllClonedAlgorithms();668 if (stopPending) StopAllClonedAlgorithms();669 }670 658 } 671 659 } … … 718 706 public event EventHandler Started; 719 707 private void OnStarted() { 720 startPending = false;721 708 ExecutionState = ExecutionState.Started; 722 709 EventHandler handler = Started; -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/FixedDataAnalysisAlgorithm.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 96 96 private void Run(object state) { 97 97 CancellationToken cancellationToken = (CancellationToken)state; 98 lastUpdateTime = DateTime. Now;98 lastUpdateTime = DateTime.UtcNow; 99 99 System.Timers.Timer timer = new System.Timers.Timer(250); 100 100 timer.AutoReset = true; … … 107 107 timer.Elapsed -= new System.Timers.ElapsedEventHandler(timer_Elapsed); 108 108 timer.Stop(); 109 ExecutionTime += DateTime. Now - lastUpdateTime;109 ExecutionTime += DateTime.UtcNow - lastUpdateTime; 110 110 } 111 111 … … 121 121 System.Timers.Timer timer = (System.Timers.Timer)sender; 122 122 timer.Enabled = false; 123 DateTime now = DateTime. Now;123 DateTime now = DateTime.UtcNow; 124 124 ExecutionTime += now - lastUpdateTime; 125 125 lastUpdateTime = now; -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceConst.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 36 37 get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; } 37 38 } 38 39 private bool HasFixedScaleParameter { 40 get { return ScaleParameter.Value != null; } 41 } 39 42 [StorableConstructor] 40 43 private CovarianceConst(bool deserializing) … … 59 62 60 63 public int GetNumberOfParameters(int numberOfVariables) { 61 return ScaleParameter.Value != null? 0 : 1;64 return HasFixedScaleParameter ? 0 : 1; 62 65 } 63 66 … … 71 74 int c = 0; 72 75 // gather parameter values 73 if ( ScaleParameter.Value != null) {76 if (HasFixedScaleParameter) { 74 77 scale = ScaleParameter.Value.Value; 75 78 } else { … … 87 90 cov.Covariance = (x, i, j) => scale; 88 91 cov.CrossCovariance = (x, xt, i, j) => scale; 89 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, columnIndices); 92 if (HasFixedScaleParameter) { 93 cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>(); 94 } else { 95 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, columnIndices); 96 } 90 97 return cov; 91 98 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinear.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 37 37 get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; } 38 38 } 39 private bool HasFixedInverseLengthParameter { 40 get { return InverseLengthParameter.Value != null; } 41 } 39 42 40 43 [StorableConstructor] … … 57 60 58 61 public int GetNumberOfParameters(int numberOfVariables) { 59 if (InverseLengthParameter.Value == null) 62 if (HasFixedInverseLengthParameter) 63 return 0; 64 else 60 65 return numberOfVariables; 61 else62 return 0;63 66 } 64 67 … … 71 74 private void GetParameterValues(double[] p, out double[] inverseLength) { 72 75 // gather parameter values 73 if ( InverseLengthParameter.Value != null) {76 if (HasFixedInverseLengthParameter) { 74 77 inverseLength = InverseLengthParameter.Value.ToArray(); 75 78 } else { … … 81 84 double[] inverseLength; 82 85 GetParameterValues(p, out inverseLength); 86 var fixedInverseLength = HasFixedInverseLengthParameter; 83 87 // create functions 84 88 var cov = new ParameterizedCovarianceFunction(); 85 89 cov.Covariance = (x, i, j) => Util.ScalarProd(x, i, j, inverseLength, columnIndices); 86 90 cov.CrossCovariance = (x, xt, i, j) => Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices); 87 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices); 91 if (fixedInverseLength) 92 cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>(); 93 else 94 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices); 88 95 return cov; 89 96 } 90 97 91 98 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double[] inverseLength, IEnumerable<int> columnIndices) { 92 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1));93 94 99 int k = 0; 95 100 foreach (int columnIndex in columnIndices) { -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMask.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 74 74 75 75 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int> columnIndices) { 76 if (columnIndices != null)77 throw new InvalidOperationException("Stacking of masking covariance functions is not supported.");78 76 var cov = CovarianceFunctionParameter.Value; 79 77 var selectedDimensions = SelectedDimensionsParameter.Value; 80 78 81 return cov.GetParameterizedCovarianceFunction(p, selectedDimensions );79 return cov.GetParameterizedCovarianceFunction(p, selectedDimensions.Intersect(columnIndices)); 82 80 } 83 81 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMaternIso.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 45 45 get { return (IConstrainedValueParameter<IntValue>)Parameters["D"]; } 46 46 } 47 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 private bool HasFixedInverseLengthParameter { 51 get { return InverseLengthParameter.Value != null; } 52 } 48 53 49 54 [StorableConstructor] … … 76 81 public int GetNumberOfParameters(int numberOfVariables) { 77 82 return 78 ( InverseLengthParameter.Value != null? 0 : 1) +79 ( ScaleParameter.Value != null? 0 : 1);83 (HasFixedInverseLengthParameter ? 0 : 1) + 84 (HasFixedScaleParameter ? 0 : 1); 80 85 } 81 86 … … 90 95 // gather parameter values 91 96 int c = 0; 92 if ( InverseLengthParameter.Value != null) {97 if (HasFixedInverseLengthParameter) { 93 98 inverseLength = InverseLengthParameter.Value.Value; 94 99 } else { … … 97 102 } 98 103 99 if ( ScaleParameter.Value != null) {104 if (HasFixedScaleParameter) { 100 105 scale = ScaleParameter.Value.Value; 101 106 } else { … … 110 115 int d = DParameter.Value.Value; 111 116 GetParameterValues(p, out scale, out inverseLength); 117 var fixedInverseLength = HasFixedInverseLengthParameter; 118 var fixedScale = HasFixedScaleParameter; 112 119 // create functions 113 120 var cov = new ParameterizedCovarianceFunction(); … … 122 129 return scale * m(d, dist); 123 130 }; 124 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, d, scale, inverseLength, columnIndices );131 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, d, scale, inverseLength, columnIndices, fixedInverseLength, fixedScale); 125 132 return cov; 126 133 } … … 149 156 150 157 151 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, IEnumerable<int> columnIndices) { 158 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, IEnumerable<int> columnIndices, 159 bool fixedInverseLength, bool fixedScale) { 152 160 double dist = i == j 153 161 ? 0.0 154 162 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices)); 155 163 156 yield return scale * dm(d, dist);157 yield return 2 * scale * m(d, dist);164 if (!fixedInverseLength) yield return scale * dm(d, dist); 165 if (!fixedScale) yield return 2 * scale * m(d, dist); 158 166 } 159 167 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNoise.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 37 37 get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; } 38 38 } 39 private bool HasFixedScaleParameter { 40 get { return ScaleParameter.Value != null; } 41 } 39 42 40 43 [StorableConstructor] … … 60 63 61 64 public int GetNumberOfParameters(int numberOfVariables) { 62 return ScaleParameter.Value != null? 0 : 1;65 return HasFixedScaleParameter ? 0 : 1; 63 66 } 64 67 … … 72 75 int c = 0; 73 76 // gather parameter values 74 if ( ScaleParameter.Value != null) {77 if (HasFixedScaleParameter) { 75 78 scale = ScaleParameter.Value.Value; 76 79 } else { … … 84 87 double scale; 85 88 GetParameterValues(p, out scale); 89 var fixedScale = HasFixedScaleParameter; 86 90 // create functions 87 91 var cov = new ParameterizedCovarianceFunction(); 88 92 cov.Covariance = (x, i, j) => i == j ? scale : 0.0; 89 cov.CrossCovariance = (x, xt, i, j) => 0.0; 90 cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1); 93 cov.CrossCovariance = (x, xt, i, j) => Util.SqrDist(x, i, xt, j, 1.0, columnIndices) < 1e-9 ? scale : 0.0; 94 if (fixedScale) 95 cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>(); 96 else 97 cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1); 91 98 return cov; 92 99 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 46 46 } 47 47 48 private bool HasFixedScaleParameter { 49 get { return ScaleParameter.Value != null; } 50 } 51 private bool HasFixedInverseLengthParameter { 52 get { return InverseLengthParameter.Value != null; } 53 } 54 private bool HasFixedPeriodParameter { 55 get { return PeriodParameter.Value != null; } 56 } 57 48 58 49 59 [StorableConstructor] … … 68 78 69 79 public int GetNumberOfParameters(int numberOfVariables) { 70 return ( ScaleParameter.Value != null? 0 : 1) +71 ( PeriodParameter.Value != null? 0 : 1) +72 ( InverseLengthParameter.Value != null? 0 : 1);80 return (HasFixedScaleParameter ? 0 : 1) + 81 (HasFixedPeriodParameter ? 0 : 1) + 82 (HasFixedInverseLengthParameter ? 0 : 1); 73 83 } 74 84 … … 82 92 83 93 84 private void GetParameterValues(double[] p, out double scale, out double period, out double inverseLength) { 94 private void GetParameterValues(double[] 95 p, out double scale, out double period, out double inverseLength) { 85 96 // gather parameter values 86 97 int c = 0; 87 if ( InverseLengthParameter.Value != null) {98 if (HasFixedInverseLengthParameter) { 88 99 inverseLength = InverseLengthParameter.Value.Value; 89 100 } else { … … 91 102 c++; 92 103 } 93 if ( PeriodParameter.Value != null) {104 if (HasFixedPeriodParameter) { 94 105 period = PeriodParameter.Value.Value; 95 106 } else { … … 97 108 c++; 98 109 } 99 if ( ScaleParameter.Value != null) {110 if (HasFixedScaleParameter) { 100 111 scale = ScaleParameter.Value.Value; 101 112 } else { … … 109 120 double inverseLength, period, scale; 110 121 GetParameterValues(p, out scale, out period, out inverseLength); 122 var fixedInverseLength = HasFixedInverseLengthParameter; 123 var fixedPeriod = HasFixedPeriodParameter; 124 var fixedScale = HasFixedScaleParameter; 111 125 // create functions 112 126 var cov = new ParameterizedCovarianceFunction(); … … 127 141 return scale * Math.Exp(-2.0 * k); 128 142 }; 129 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength );143 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength, fixedInverseLength, fixedPeriod, fixedScale); 130 144 return cov; 131 145 } 132 146 133 147 134 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength) { 135 double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period; 136 double gradient = Math.Sin(v) * inverseLength; 148 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength, 149 bool fixedInverseLength, bool fixedPeriod, bool fixedScale) { 150 double k = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period; 151 double gradient = Math.Sin(k) * inverseLength; 137 152 gradient *= gradient; 138 yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient; 139 double r = Math.Sin(v) * inverseLength; 140 yield return 4.0 * scale * inverseLength * Math.Exp(-2 * r * r) * r * Math.Cos(v) * v; 141 yield return 2.0 * scale * Math.Exp(-2 * gradient); 153 if (!fixedInverseLength) yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient; 154 if (!fixedPeriod) { 155 double r = Math.Sin(k) * inverseLength; 156 yield return 2.0 * k * scale * Math.Exp(-2 * r * r) * Math.Sin(2 * k) * inverseLength * inverseLength; 157 } 158 if (!fixedScale) 159 yield return 2.0 * scale * Math.Exp(-2 * gradient); 160 142 161 } 143 162 -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceProduct.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 45 45 get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; } 46 46 } 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 private bool HasFixedInverseLengthParameter { 51 get { return InverseLengthParameter.Value != null; } 52 } 53 private bool HasFixedShapeParameter { 54 get { return ShapeParameter.Value != null; } 55 } 47 56 48 57 [StorableConstructor] … … 71 80 public int GetNumberOfParameters(int numberOfVariables) { 72 81 return 73 ( ScaleParameter.Value != null? 0 : 1) +74 ( ShapeParameter.Value != null? 0 : 1) +75 ( InverseLengthParameter.Value != null? 0 : numberOfVariables);82 (HasFixedScaleParameter ? 0 : 1) + 83 (HasFixedShapeParameter ? 0 : 1) + 84 (HasFixedInverseLengthParameter ? 0 : numberOfVariables); 76 85 } 77 86 … … 88 97 int c = 0; 89 98 // gather parameter values 90 if (ScaleParameter.Value != null) { 99 if (HasFixedInverseLengthParameter) { 100 inverseLength = InverseLengthParameter.Value.ToArray(); 101 } else { 102 int length = p.Length; 103 if (!HasFixedScaleParameter) length--; 104 if (!HasFixedShapeParameter) length--; 105 inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray(); 106 c += inverseLength.Length; 107 } 108 if (HasFixedScaleParameter) { 91 109 scale = ScaleParameter.Value.Value; 92 110 } else { … … 94 112 c++; 95 113 } 96 if ( ShapeParameter.Value != null) {114 if (HasFixedShapeParameter) { 97 115 shape = ShapeParameter.Value.Value; 98 116 } else { 99 117 shape = Math.Exp(p[c]); 100 118 c++; 101 }102 if (InverseLengthParameter.Value != null) {103 inverseLength = InverseLengthParameter.Value.ToArray();104 } else {105 inverseLength = p.Skip(2).Select(e => 1.0 / Math.Exp(e)).ToArray();106 c += inverseLength.Length;107 119 } 108 120 if (p.Length != c) throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovarianceRationalQuadraticArd", "p"); … … 113 125 double[] inverseLength; 114 126 GetParameterValues(p, out scale, out shape, out inverseLength); 127 var fixedInverseLength = HasFixedInverseLengthParameter; 128 var fixedScale = HasFixedScaleParameter; 129 var fixedShape = HasFixedShapeParameter; 115 130 // create functions 116 131 var cov = new ParameterizedCovarianceFunction(); … … 125 140 return scale * Math.Pow(1 + 0.5 * d / shape, -shape); 126 141 }; 127 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength );142 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape); 128 143 return cov; 129 144 } 130 145 131 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength ) {132 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1));146 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength, 147 bool fixedInverseLength, bool fixedScale, bool fixedShape) { 133 148 double d = i == j 134 149 ? 0.0 … … 136 151 double b = 1 + 0.5 * d / shape; 137 152 int k = 0; 138 foreach (var columnIndex in columnIndices) { 139 yield return scale * Math.Pow(b, -shape - 1) * Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 140 k++; 153 if (!fixedInverseLength) { 154 foreach (var columnIndex in columnIndices) { 155 yield return 156 scale * Math.Pow(b, -shape - 1) * 157 Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 158 k++; 159 } 141 160 } 142 yield return 2 * scale * Math.Pow(b, -shape);143 yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));161 if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape); 162 if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b)); 144 163 } 145 164 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 44 44 get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; } 45 45 } 46 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 private bool HasFixedInverseLengthParameter { 51 get { return InverseLengthParameter.Value != null; } 52 } 53 private bool HasFixedShapeParameter { 54 get { return ShapeParameter.Value != null; } 55 } 56 57 46 58 [StorableConstructor] 47 59 private CovarianceRationalQuadraticIso(bool deserializing) … … 68 80 69 81 public int GetNumberOfParameters(int numberOfVariables) { 70 return ( ScaleParameter.Value != null? 0 : 1) +71 ( ShapeParameter.Value != null? 0 : 1) +72 ( InverseLengthParameter.Value != null? 0 : 1);82 return (HasFixedScaleParameter ? 0 : 1) + 83 (HasFixedShapeParameter ? 0 : 1) + 84 (HasFixedInverseLengthParameter ? 0 : 1); 73 85 } 74 86 … … 84 96 int c = 0; 85 97 // gather parameter values 86 if (ScaleParameter.Value != null) { 98 if (HasFixedInverseLengthParameter) { 99 inverseLength = InverseLengthParameter.Value.Value; 100 } else { 101 inverseLength = 1.0 / Math.Exp(p[c]); 102 c++; 103 } 104 if (HasFixedScaleParameter) { 87 105 scale = ScaleParameter.Value.Value; 88 106 } else { … … 90 108 c++; 91 109 } 92 if ( ShapeParameter.Value != null) {110 if (HasFixedShapeParameter) { 93 111 shape = ShapeParameter.Value.Value; 94 112 } else { 95 113 shape = Math.Exp(p[c]); 96 c++;97 }98 if (InverseLengthParameter.Value != null) {99 inverseLength = InverseLengthParameter.Value.Value;100 } else {101 inverseLength = 1.0 / Math.Exp(p[c]);102 114 c++; 103 115 } … … 108 120 double scale, shape, inverseLength; 109 121 GetParameterValues(p, out scale, out shape, out inverseLength); 122 var fixedInverseLength = HasFixedInverseLengthParameter; 123 var fixedScale = HasFixedScaleParameter; 124 var fixedShape = HasFixedShapeParameter; 110 125 // create functions 111 126 var cov = new ParameterizedCovarianceFunction(); … … 114 129 ? 0.0 115 130 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 116 return s hape * Math.Pow(1 + 0.5 * d / shape, -shape);131 return scale * Math.Pow(1 + 0.5 * d / shape, -shape); 117 132 }; 118 133 cov.CrossCovariance = (x, xt, i, j) => { … … 120 135 return scale * Math.Pow(1 + 0.5 * d / shape, -shape); 121 136 }; 122 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength );137 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape); 123 138 return cov; 124 139 } 125 140 126 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength) { 141 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength, 142 bool fixedInverseLength, bool fixedScale, bool fixedShape) { 127 143 double d = i == j 128 144 ? 0.0 … … 130 146 131 147 double b = 1 + 0.5 * d / shape; 132 yield return scale * Math.Pow(b, -shape - 1) * d;133 yield return 2 * scale * Math.Pow(b, -shape);134 yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));148 if (!fixedInverseLength) yield return scale * Math.Pow(b, -shape - 1) * d; 149 if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape); 150 if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b)); 135 151 } 136 152 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceScale.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 37 37 get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; } 38 38 } 39 private bool HasFixedScaleParameter { 40 get { return ScaleParameter.Value != null; } 41 } 39 42 40 43 public IValueParameter<ICovarianceFunction> CovarianceFunctionParameter { … … 65 68 66 69 public int GetNumberOfParameters(int numberOfVariables) { 67 return ( ScaleParameter.Value != null? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables);70 return (HasFixedScaleParameter ? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables); 68 71 } 69 72 … … 77 80 private void GetParameterValues(double[] p, out double scale) { 78 81 // gather parameter values 79 if ( ScaleParameter.Value != null) {82 if (HasFixedScaleParameter) { 80 83 scale = ScaleParameter.Value.Value; 81 84 } else { … … 87 90 double scale; 88 91 GetParameterValues(p, out scale); 92 var fixedScale = HasFixedScaleParameter; 89 93 var subCov = CovarianceFunctionParameter.Value.GetParameterizedCovarianceFunction(p.Skip(1).ToArray(), columnIndices); 90 94 // create functions … … 92 96 cov.Covariance = (x, i, j) => scale * subCov.Covariance(x, i, j); 93 97 cov.CrossCovariance = (x, xt, i, j) => scale * subCov.CrossCovariance(x, xt, i, j); 94 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov );98 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov, fixedScale); 95 99 return cov; 96 100 } 97 101 98 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov) { 99 yield return 2 * scale * cov.Covariance(x, i, j); 102 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov, 103 bool fixedScale) { 104 if (!fixedScale) { 105 yield return 2 * scale * cov.Covariance(x, i, j); 106 } 100 107 foreach (var g in cov.CovarianceGradient(x, i, j)) 101 108 yield return scale * g; -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 40 40 get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; } 41 41 } 42 private bool HasFixedInverseLengthParameter { 43 get { return InverseLengthParameter.Value != null; } 44 } 45 private bool HasFixedScaleParameter { 46 get { return ScaleParameter.Value != null; } 47 } 42 48 43 49 [StorableConstructor] … … 61 67 public int GetNumberOfParameters(int numberOfVariables) { 62 68 return 63 ( ScaleParameter.Value != null? 0 : 1) +64 ( InverseLengthParameter.Value != null? 0 : numberOfVariables);69 (HasFixedScaleParameter ? 0 : 1) + 70 (HasFixedInverseLengthParameter ? 0 : numberOfVariables); 65 71 } 66 72 … … 76 82 int c = 0; 77 83 // gather parameter values 78 if (ScaleParameter.Value != null) { 84 if (HasFixedInverseLengthParameter) { 85 inverseLength = InverseLengthParameter.Value.ToArray(); 86 } else { 87 int length = p.Length; 88 if (!HasFixedScaleParameter) length--; 89 inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray(); 90 c += inverseLength.Length; 91 } 92 if (HasFixedScaleParameter) { 79 93 scale = ScaleParameter.Value.Value; 80 94 } else { 81 95 scale = Math.Exp(2 * p[c]); 82 96 c++; 83 }84 if (InverseLengthParameter.Value != null) {85 inverseLength = InverseLengthParameter.Value.ToArray();86 } else {87 inverseLength = p.Skip(1).Select(e => 1.0 / Math.Exp(e)).ToArray();88 c += inverseLength.Length;89 97 } 90 98 if (p.Length != c) throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovarianceSquaredExponentialArd", "p"); … … 95 103 double[] inverseLength; 96 104 GetParameterValues(p, out scale, out inverseLength); 105 var fixedInverseLength = HasFixedInverseLengthParameter; 106 var fixedScale = HasFixedScaleParameter; 97 107 // create functions 98 108 var cov = new ParameterizedCovarianceFunction(); … … 107 117 return scale * Math.Exp(-d / 2.0); 108 118 }; 109 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength );119 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength, fixedInverseLength, fixedScale); 110 120 return cov; 111 121 } 112 122 113 114 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength ) {115 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1));123 // order of returned gradients must match the order in GetParameterValues! 124 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength, 125 bool fixedInverseLength, bool fixedScale) { 116 126 double d = i == j 117 127 ? 0.0 118 128 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 129 119 130 int k = 0; 120 foreach (var columnIndex in columnIndices) { 121 double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 122 yield return scale * Math.Exp(-d / 2.0) * sqrDist; 123 k++; 131 if (!fixedInverseLength) { 132 foreach (var columnIndex in columnIndices) { 133 double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 134 yield return scale * Math.Exp(-d / 2.0) * sqrDist; 135 k++; 136 } 124 137 } 125 126 yield return 2.0 * scale * Math.Exp(-d / 2.0); 138 if (!fixedScale) yield return 2.0 * scale * Math.Exp(-d / 2.0); 127 139 } 128 140 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialIso.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 42 42 } 43 43 44 private bool HasFixedInverseLengthParameter { 45 get { return InverseLengthParameter.Value != null; } 46 } 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 44 51 [StorableConstructor] 45 52 private CovarianceSquaredExponentialIso(bool deserializing) … … 66 73 public int GetNumberOfParameters(int numberOfVariables) { 67 74 return 68 ( ScaleParameter.Value != null? 0 : 1) +69 ( InverseLengthParameter.Value != null? 0 : 1);75 (HasFixedScaleParameter ? 0 : 1) + 76 (HasFixedInverseLengthParameter ? 0 : 1); 70 77 } 71 78 … … 81 88 // gather parameter values 82 89 int c = 0; 83 if ( InverseLengthParameter.Value != null) {90 if (HasFixedInverseLengthParameter) { 84 91 inverseLength = InverseLengthParameter.Value.Value; 85 92 } else { … … 88 95 } 89 96 90 if ( ScaleParameter.Value != null) {97 if (HasFixedScaleParameter) { 91 98 scale = ScaleParameter.Value.Value; 92 99 } else { … … 100 107 double inverseLength, scale; 101 108 GetParameterValues(p, out scale, out inverseLength); 109 var fixedInverseLength = HasFixedInverseLengthParameter; 110 var fixedScale = HasFixedScaleParameter; 102 111 // create functions 103 112 var cov = new ParameterizedCovarianceFunction(); … … 112 121 return scale * Math.Exp(-d / 2.0); 113 122 }; 114 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices); 123 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices, 124 fixedInverseLength, fixedScale); 115 125 return cov; 116 126 } 117 127 118 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices) { 128 // order of returned gradients must match the order in GetParameterValues! 129 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices, 130 bool fixedInverseLength, bool fixedScale) { 119 131 double d = i == j 120 132 ? 0.0 121 133 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 122 134 double g = Math.Exp(-d / 2.0); 123 yield return sf2 * g * d;124 yield return 2.0 * sf2 * g;135 if (!fixedInverseLength) yield return sf2 * g * d; 136 if (!fixedScale) yield return 2.0 * sf2 * g; 125 137 } 126 138 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSum.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassification.cs ¶
r8623 r10553 2 2 #region License Information 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. … … 22 22 23 23 using System; 24 using System.Linq; 24 25 using HeuristicLab.Algorithms.GradientDescent; 25 26 using HeuristicLab.Common; … … 30 31 using HeuristicLab.Parameters; 31 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 using HeuristicLab.PluginInfrastructure; 32 34 using HeuristicLab.Problems.DataAnalysis; 33 35 … … 39 41 [Creatable("Data Analysis")] 40 42 [StorableClass] 41 public sealed class GaussianProcessClassification : EngineAlgorithm, IStorableContent {43 public sealed class GaussianProcessClassification : GaussianProcessBase, IStorableContent { 42 44 public string Filename { get; set; } 43 45 … … 48 50 } 49 51 50 private const string MeanFunctionParameterName = "MeanFunction"; 51 private const string CovarianceFunctionParameterName = "CovarianceFunction"; 52 private const string MinimizationIterationsParameterName = "Iterations"; 53 private const string ApproximateGradientsParameterName = "ApproximateGradients"; 54 private const string SeedParameterName = "Seed"; 55 private const string SetSeedRandomlyParameterName = "SetSeedRandomly"; 52 private const string ModelParameterName = "Model"; 56 53 57 54 #region parameter properties 58 public I ValueParameter<IMeanFunction> MeanFunctionParameter {59 get { return (I ValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }55 public IConstrainedValueParameter<IGaussianProcessClassificationModelCreator> GaussianProcessModelCreatorParameter { 56 get { return (IConstrainedValueParameter<IGaussianProcessClassificationModelCreator>)Parameters[ModelCreatorParameterName]; } 60 57 } 61 public I ValueParameter<ICovarianceFunction> CovarianceFunctionParameter {62 get { return (I ValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }58 public IFixedValueParameter<GaussianProcessClassificationSolutionCreator> GaussianProcessSolutionCreatorParameter { 59 get { return (IFixedValueParameter<GaussianProcessClassificationSolutionCreator>)Parameters[SolutionCreatorParameterName]; } 63 60 } 64 public IValueParameter<IntValue> MinimizationIterationsParameter {65 get { return (IValueParameter<IntValue>)Parameters[MinimizationIterationsParameterName]; }66 }67 public IValueParameter<IntValue> SeedParameter {68 get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; }69 }70 public IValueParameter<BoolValue> SetSeedRandomlyParameter {71 get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; }72 }73 #endregion74 #region properties75 public IMeanFunction MeanFunction {76 set { MeanFunctionParameter.Value = value; }77 get { return MeanFunctionParameter.Value; }78 }79 public ICovarianceFunction CovarianceFunction {80 set { CovarianceFunctionParameter.Value = value; }81 get { return CovarianceFunctionParameter.Value; }82 }83 public int MinimizationIterations {84 set { MinimizationIterationsParameter.Value.Value = value; }85 get { return MinimizationIterationsParameter.Value.Value; }86 }87 public int Seed { get { return SeedParameter.Value.Value; } set { SeedParameter.Value.Value = value; } }88 public bool SetSeedRandomly { get { return SetSeedRandomlyParameter.Value.Value; } set { SetSeedRandomlyParameter.Value.Value = value; } }89 61 #endregion 90 62 … … 93 65 private GaussianProcessClassification(GaussianProcessClassification original, Cloner cloner) 94 66 : base(original, cloner) { 67 RegisterEventHandlers(); 95 68 } 96 69 public GaussianProcessClassification() 97 : base( ) {70 : base(new ClassificationProblem()) { 98 71 this.name = ItemName; 99 72 this.description = ItemDescription; 100 73 101 Problem = new ClassificationProblem(); 74 var modelCreators = ApplicationManager.Manager.GetInstances<IGaussianProcessClassificationModelCreator>(); 75 var defaultModelCreator = modelCreators.First(c => c is GaussianProcessClassificationModelCreator); 102 76 103 Parameters.Add(new ValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.", new MeanConst())); 104 Parameters.Add(new ValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.", new CovarianceSquaredExponentialIso())); 105 Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20))); 106 Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 107 Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 77 // GP regression and classification algorithms only differ in the model and solution creators, 78 // thus we use a common base class and use operator parameters to implement the specific versions. 79 // Different model creators can be implemented, 80 // but the solution creator is implemented in a generic fashion already and we don't allow derived solution creators 81 Parameters.Add(new ConstrainedValueParameter<IGaussianProcessClassificationModelCreator>(ModelCreatorParameterName, "The operator to create the Gaussian process model.", 82 new ItemSet<IGaussianProcessClassificationModelCreator>(modelCreators), defaultModelCreator)); 83 // this parameter is not intended to be changed, 84 Parameters.Add(new FixedValueParameter<GaussianProcessClassificationSolutionCreator>(SolutionCreatorParameterName, "The solution creator for the algorithm", 85 new GaussianProcessClassificationSolutionCreator())); 86 Parameters[SolutionCreatorParameterName].Hidden = true; 108 87 109 Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "Indicates that gradients should not be approximated (necessary for LM-BFGS).", new BoolValue(false))); 110 Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed 111 112 var randomCreator = new HeuristicLab.Random.RandomCreator(); 113 var gpInitializer = new GaussianProcessHyperparameterInitializer(); 114 var bfgsInitializer = new LbfgsInitializer(); 115 var makeStep = new LbfgsMakeStep(); 116 var branch = new ConditionalBranch(); 117 var modelCreator = new GaussianProcessClassificationModelCreator(); 118 var updateResults = new LbfgsUpdateResults(); 119 var analyzer = new LbfgsAnalyzer(); 120 var finalModelCreator = new GaussianProcessClassificationModelCreator(); 121 var finalAnalyzer = new LbfgsAnalyzer(); 122 var solutionCreator = new GaussianProcessClassificationSolutionCreator(); 123 124 OperatorGraph.InitialOperator = randomCreator; 125 randomCreator.SeedParameter.ActualName = SeedParameterName; 126 randomCreator.SeedParameter.Value = null; 127 randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName; 128 randomCreator.SetSeedRandomlyParameter.Value = null; 129 randomCreator.Successor = gpInitializer; 130 131 gpInitializer.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 132 gpInitializer.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 133 gpInitializer.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 gpInitializer.HyperparameterParameter.ActualName = modelCreator.HyperparameterParameter.Name; 135 gpInitializer.RandomParameter.ActualName = randomCreator.RandomParameter.Name; 136 gpInitializer.Successor = bfgsInitializer; 137 138 bfgsInitializer.IterationsParameter.ActualName = MinimizationIterationsParameterName; 139 bfgsInitializer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 140 bfgsInitializer.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 141 bfgsInitializer.Successor = makeStep; 142 143 makeStep.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 144 makeStep.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 145 makeStep.Successor = branch; 146 147 branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name; 148 branch.FalseBranch = modelCreator; 149 branch.TrueBranch = finalModelCreator; 150 151 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 152 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 153 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 154 modelCreator.Successor = updateResults; 155 156 updateResults.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 157 updateResults.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 158 updateResults.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 159 updateResults.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 160 updateResults.Successor = analyzer; 161 162 analyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 163 analyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 164 analyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 165 analyzer.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 166 analyzer.PointsTableParameter.ActualName = "Hyperparameter table"; 167 analyzer.QualityGradientsTableParameter.ActualName = "Gradients table"; 168 analyzer.QualitiesTableParameter.ActualName = "Negative log likelihood table"; 169 analyzer.Successor = makeStep; 170 171 finalModelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 172 finalModelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 173 finalModelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 174 finalModelCreator.HyperparameterParameter.ActualName = bfgsInitializer.PointParameter.ActualName; 175 finalModelCreator.Successor = finalAnalyzer; 176 177 finalAnalyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 178 finalAnalyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 179 finalAnalyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 180 finalAnalyzer.PointsTableParameter.ActualName = analyzer.PointsTableParameter.ActualName; 181 finalAnalyzer.QualityGradientsTableParameter.ActualName = analyzer.QualityGradientsTableParameter.ActualName; 182 finalAnalyzer.QualitiesTableParameter.ActualName = analyzer.QualitiesTableParameter.ActualName; 183 finalAnalyzer.Successor = solutionCreator; 184 185 solutionCreator.ModelParameter.ActualName = finalModelCreator.ModelParameter.Name; 186 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 88 ParameterizedModelCreators(); 89 ParameterizeSolutionCreator(GaussianProcessSolutionCreatorParameter.Value); 90 RegisterEventHandlers(); 187 91 } 188 92 93 189 94 [StorableHook(HookType.AfterDeserialization)] 190 private void AfterDeserialization() { } 95 private void AfterDeserialization() { 96 RegisterEventHandlers(); 97 } 191 98 192 99 public override IDeepCloneable Clone(Cloner cloner) { 193 100 return new GaussianProcessClassification(this, cloner); 194 101 } 102 103 #region events 104 private void RegisterEventHandlers() { 105 GaussianProcessModelCreatorParameter.ValueChanged += ModelCreatorParameter_ValueChanged; 106 } 107 108 private void ModelCreatorParameter_ValueChanged(object sender, EventArgs e) { 109 ParameterizedModelCreator(GaussianProcessModelCreatorParameter.Value); 110 } 111 #endregion 112 113 private void ParameterizedModelCreators() { 114 foreach (var creator in GaussianProcessModelCreatorParameter.ValidValues) { 115 ParameterizedModelCreator(creator); 116 } 117 } 118 119 private void ParameterizedModelCreator(IGaussianProcessClassificationModelCreator modelCreator) { 120 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 121 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 122 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 123 124 // parameter names fixed by the algorithm 125 modelCreator.ModelParameter.ActualName = ModelParameterName; 126 modelCreator.HyperparameterParameter.ActualName = HyperparameterParameterName; 127 modelCreator.HyperparameterGradientsParameter.ActualName = HyperparameterGradientsParameterName; 128 modelCreator.NegativeLogLikelihoodParameter.ActualName = NegativeLogLikelihoodParameterName; 129 } 130 131 private void ParameterizeSolutionCreator(GaussianProcessClassificationSolutionCreator solutionCreator) { 132 solutionCreator.ModelParameter.ActualName = ModelParameterName; 133 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 } 195 135 } 196 136 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationModelCreator.cs ¶
r8623 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 34 34 [Item(Name = "GaussianProcessClassificationModelCreator", 35 35 Description = "Creates a Gaussian process model for least-squares classification given the data, the hyperparameters, a mean function, and a covariance function.")] 36 public sealed class GaussianProcessClassificationModelCreator : GaussianProcessModelCreator {36 public sealed class GaussianProcessClassificationModelCreator : GaussianProcessModelCreator, IGaussianProcessClassificationModelCreator { 37 37 private const string ProblemDataParameterName = "ProblemData"; 38 38 -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationSolutionCreator.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessHyperparameterInitializer.cs ¶
r8732 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 284 284 var kss = new double[newN]; 285 285 double[,] sWKs = new double[n, newN]; 286 var cov = covarianceFunction.GetParameterizedCovarianceFunction(covarianceParameter, Enumerable.Range(0, newX.GetLength(1)));286 var cov = covarianceFunction.GetParameterizedCovarianceFunction(covarianceParameter, Enumerable.Range(0, x.GetLength(1))); 287 287 288 288 // for stddev -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModelCreator.cs ¶
r8401 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs ¶
r8615 r10553 2 2 #region License Information 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. … … 22 22 23 23 using System; 24 using System.Linq; 24 25 using HeuristicLab.Algorithms.GradientDescent; 25 26 using HeuristicLab.Common; … … 30 31 using HeuristicLab.Parameters; 31 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 using HeuristicLab.PluginInfrastructure; 32 34 using HeuristicLab.Problems.DataAnalysis; 33 35 … … 39 41 [Creatable("Data Analysis")] 40 42 [StorableClass] 41 public sealed class GaussianProcessRegression : EngineAlgorithm, IStorableContent {43 public sealed class GaussianProcessRegression : GaussianProcessBase, IStorableContent { 42 44 public string Filename { get; set; } 43 45 … … 48 50 } 49 51 50 private const string MeanFunctionParameterName = "MeanFunction"; 51 private const string CovarianceFunctionParameterName = "CovarianceFunction"; 52 private const string MinimizationIterationsParameterName = "Iterations"; 53 private const string ApproximateGradientsParameterName = "ApproximateGradients"; 54 private const string SeedParameterName = "Seed"; 55 private const string SetSeedRandomlyParameterName = "SetSeedRandomly"; 52 private const string ModelParameterName = "Model"; 56 53 57 54 #region parameter properties 58 public I ValueParameter<IMeanFunction> MeanFunctionParameter {59 get { return (I ValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }55 public IConstrainedValueParameter<IGaussianProcessRegressionModelCreator> GaussianProcessModelCreatorParameter { 56 get { return (IConstrainedValueParameter<IGaussianProcessRegressionModelCreator>)Parameters[ModelCreatorParameterName]; } 60 57 } 61 public I ValueParameter<ICovarianceFunction> CovarianceFunctionParameter {62 get { return (I ValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }58 public IFixedValueParameter<GaussianProcessRegressionSolutionCreator> GaussianProcessSolutionCreatorParameter { 59 get { return (IFixedValueParameter<GaussianProcessRegressionSolutionCreator>)Parameters[SolutionCreatorParameterName]; } 63 60 } 64 public IValueParameter<IntValue> MinimizationIterationsParameter {65 get { return (IValueParameter<IntValue>)Parameters[MinimizationIterationsParameterName]; }66 }67 public IValueParameter<IntValue> SeedParameter {68 get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; }69 }70 public IValueParameter<BoolValue> SetSeedRandomlyParameter {71 get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; }72 }73 #endregion74 #region properties75 public IMeanFunction MeanFunction {76 set { MeanFunctionParameter.Value = value; }77 get { return MeanFunctionParameter.Value; }78 }79 public ICovarianceFunction CovarianceFunction {80 set { CovarianceFunctionParameter.Value = value; }81 get { return CovarianceFunctionParameter.Value; }82 }83 public int MinimizationIterations {84 set { MinimizationIterationsParameter.Value.Value = value; }85 get { return MinimizationIterationsParameter.Value.Value; }86 }87 public int Seed { get { return SeedParameter.Value.Value; } set { SeedParameter.Value.Value = value; } }88 public bool SetSeedRandomly { get { return SetSeedRandomlyParameter.Value.Value; } set { SetSeedRandomlyParameter.Value.Value = value; } }89 61 #endregion 90 62 … … 93 65 private GaussianProcessRegression(GaussianProcessRegression original, Cloner cloner) 94 66 : base(original, cloner) { 67 RegisterEventHandlers(); 95 68 } 96 69 public GaussianProcessRegression() 97 : base( ) {70 : base(new RegressionProblem()) { 98 71 this.name = ItemName; 99 72 this.description = ItemDescription; 100 73 101 Problem = new RegressionProblem(); 74 var modelCreators = ApplicationManager.Manager.GetInstances<IGaussianProcessRegressionModelCreator>(); 75 var defaultModelCreator = modelCreators.First(c => c is GaussianProcessRegressionModelCreator); 102 76 103 Parameters.Add(new ValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.", new MeanConst())); 104 Parameters.Add(new ValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.", new CovarianceSquaredExponentialIso())); 105 Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20))); 106 Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 107 Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 77 // GP regression and classification algorithms only differ in the model and solution creators, 78 // thus we use a common base class and use operator parameters to implement the specific versions. 79 // Different model creators can be implemented, 80 // but the solution creator is implemented in a generic fashion already and we don't allow derived solution creators 81 Parameters.Add(new ConstrainedValueParameter<IGaussianProcessRegressionModelCreator>(ModelCreatorParameterName, "The operator to create the Gaussian process model.", 82 new ItemSet<IGaussianProcessRegressionModelCreator>(modelCreators), defaultModelCreator)); 83 // this parameter is not intended to be changed, 84 Parameters.Add(new FixedValueParameter<GaussianProcessRegressionSolutionCreator>(SolutionCreatorParameterName, "The solution creator for the algorithm", 85 new GaussianProcessRegressionSolutionCreator())); 86 Parameters[SolutionCreatorParameterName].Hidden = true; 108 87 109 Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "Indicates that gradients should not be approximated (necessary for LM-BFGS).", new BoolValue(false))); 110 Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed 111 112 var randomCreator = new HeuristicLab.Random.RandomCreator(); 113 var gpInitializer = new GaussianProcessHyperparameterInitializer(); 114 var bfgsInitializer = new LbfgsInitializer(); 115 var makeStep = new LbfgsMakeStep(); 116 var branch = new ConditionalBranch(); 117 var modelCreator = new GaussianProcessRegressionModelCreator(); 118 var updateResults = new LbfgsUpdateResults(); 119 var analyzer = new LbfgsAnalyzer(); 120 var finalModelCreator = new GaussianProcessRegressionModelCreator(); 121 var finalAnalyzer = new LbfgsAnalyzer(); 122 var solutionCreator = new GaussianProcessRegressionSolutionCreator(); 123 124 OperatorGraph.InitialOperator = randomCreator; 125 randomCreator.SeedParameter.ActualName = SeedParameterName; 126 randomCreator.SeedParameter.Value = null; 127 randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName; 128 randomCreator.SetSeedRandomlyParameter.Value = null; 129 randomCreator.Successor = gpInitializer; 130 131 gpInitializer.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 132 gpInitializer.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 133 gpInitializer.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 gpInitializer.HyperparameterParameter.ActualName = modelCreator.HyperparameterParameter.Name; 135 gpInitializer.RandomParameter.ActualName = randomCreator.RandomParameter.Name; 136 gpInitializer.Successor = bfgsInitializer; 137 138 bfgsInitializer.IterationsParameter.ActualName = MinimizationIterationsParameterName; 139 bfgsInitializer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 140 bfgsInitializer.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 141 bfgsInitializer.Successor = makeStep; 142 143 makeStep.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 144 makeStep.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 145 makeStep.Successor = branch; 146 147 branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name; 148 branch.FalseBranch = modelCreator; 149 branch.TrueBranch = finalModelCreator; 150 151 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 152 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 153 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 154 modelCreator.Successor = updateResults; 155 156 updateResults.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 157 updateResults.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 158 updateResults.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 159 updateResults.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 160 updateResults.Successor = analyzer; 161 162 analyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 163 analyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 164 analyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 165 analyzer.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 166 analyzer.PointsTableParameter.ActualName = "Hyperparameter table"; 167 analyzer.QualityGradientsTableParameter.ActualName = "Gradients table"; 168 analyzer.QualitiesTableParameter.ActualName = "Negative log likelihood table"; 169 analyzer.Successor = makeStep; 170 171 finalModelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 172 finalModelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 173 finalModelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 174 finalModelCreator.HyperparameterParameter.ActualName = bfgsInitializer.PointParameter.ActualName; 175 finalModelCreator.Successor = finalAnalyzer; 176 177 finalAnalyzer.QualityParameter.ActualName = modelCreator.NegativeLogLikelihoodParameter.Name; 178 finalAnalyzer.PointParameter.ActualName = modelCreator.HyperparameterParameter.Name; 179 finalAnalyzer.QualityGradientsParameter.ActualName = modelCreator.HyperparameterGradientsParameter.Name; 180 finalAnalyzer.PointsTableParameter.ActualName = analyzer.PointsTableParameter.ActualName; 181 finalAnalyzer.QualityGradientsTableParameter.ActualName = analyzer.QualityGradientsTableParameter.ActualName; 182 finalAnalyzer.QualitiesTableParameter.ActualName = analyzer.QualitiesTableParameter.ActualName; 183 finalAnalyzer.Successor = solutionCreator; 184 185 solutionCreator.ModelParameter.ActualName = finalModelCreator.ModelParameter.Name; 186 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 88 ParameterizedModelCreators(); 89 ParameterizeSolutionCreator(GaussianProcessSolutionCreatorParameter.Value); 90 RegisterEventHandlers(); 187 91 } 188 92 93 189 94 [StorableHook(HookType.AfterDeserialization)] 190 private void AfterDeserialization() { } 95 private void AfterDeserialization() { 96 RegisterEventHandlers(); 97 } 191 98 192 99 public override IDeepCloneable Clone(Cloner cloner) { 193 100 return new GaussianProcessRegression(this, cloner); 194 101 } 102 103 #region events 104 private void RegisterEventHandlers() { 105 GaussianProcessModelCreatorParameter.ValueChanged += ModelCreatorParameter_ValueChanged; 106 } 107 108 private void ModelCreatorParameter_ValueChanged(object sender, EventArgs e) { 109 ParameterizedModelCreator(GaussianProcessModelCreatorParameter.Value); 110 } 111 #endregion 112 113 private void ParameterizedModelCreators() { 114 foreach (var creator in GaussianProcessModelCreatorParameter.ValidValues) { 115 ParameterizedModelCreator(creator); 116 } 117 } 118 119 private void ParameterizedModelCreator(IGaussianProcessRegressionModelCreator modelCreator) { 120 modelCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 121 modelCreator.MeanFunctionParameter.ActualName = MeanFunctionParameterName; 122 modelCreator.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName; 123 124 // parameter names fixed by the algorithm 125 modelCreator.ModelParameter.ActualName = ModelParameterName; 126 modelCreator.HyperparameterParameter.ActualName = HyperparameterParameterName; 127 modelCreator.HyperparameterGradientsParameter.ActualName = HyperparameterGradientsParameterName; 128 modelCreator.NegativeLogLikelihoodParameter.ActualName = NegativeLogLikelihoodParameterName; 129 } 130 131 private void ParameterizeSolutionCreator(GaussianProcessRegressionSolutionCreator solutionCreator) { 132 solutionCreator.ModelParameter.ActualName = ModelParameterName; 133 solutionCreator.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name; 134 } 195 135 } 196 136 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionModelCreator.cs ¶
r8484 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 34 34 [Item(Name = "GaussianProcessRegressionModelCreator", 35 35 Description = "Creates a Gaussian process model for regression given the data, the hyperparameters, a mean function, and a covariance function.")] 36 public sealed class GaussianProcessRegressionModelCreator : GaussianProcessModelCreator {36 public sealed class GaussianProcessRegressionModelCreator : GaussianProcessModelCreator, IGaussianProcessRegressionModelCreator { 37 37 private const string ProblemDataParameterName = "ProblemData"; 38 38 -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolution.cs ¶
r8837 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/IMeanFunction.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/Util.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj ¶
r9074 r10553 101 101 </PropertyGroup> 102 102 <ItemGroup> 103 <Reference Include="ALGLIB-3. 6.0">104 <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3. 6.0.dll</HintPath>103 <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 104 <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath> 105 105 <Private>False</Private> 106 106 </Reference> … … 200 200 </Compile> 201 201 <Compile Include="FixedDataAnalysisAlgorithm.cs" /> 202 <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceSpectralMixture.cs" /> 203 <Compile Include="GaussianProcess\CovarianceFunctions\CovariancePiecewisePolynomial.cs" /> 204 <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceNeuralNetwork.cs" /> 205 <Compile Include="GaussianProcess\CovarianceFunctions\CovariancePolynomial.cs" /> 206 <Compile Include="GaussianProcess\GaussianProcessBase.cs" /> 202 207 <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceConst.cs"> 203 208 <SubType>Code</SubType> … … 264 269 <Compile Include="GaussianProcess\GaussianProcessRegressionSolution.cs" /> 265 270 <Compile Include="GaussianProcess\ICovarianceFunction.cs" /> 271 <Compile Include="Interfaces\IGaussianProcessClassificationModelCreator.cs" /> 272 <Compile Include="Interfaces\IGaussianProcessRegressionModelCreator.cs" /> 273 <Compile Include="Interfaces\IGaussianProcessModelCreator.cs" /> 266 274 <Compile Include="Interfaces\IGaussianProcessModel.cs" /> 267 275 <Compile Include="Interfaces\IGaussianProcessSolution.cs" /> … … 304 312 <Compile Include="Nca\Initialization\INcaInitializer.cs" /> 305 313 <Compile Include="Nca\Initialization\LdaInitializer.cs" /> 314 <Compile Include="Nca\Initialization\NcaInitializer.cs" /> 306 315 <Compile Include="Nca\Initialization\PcaInitializer.cs" /> 307 316 <Compile Include="Nca\Initialization\RandomInitializer.cs" /> 308 317 <Compile Include="Nca\Matrix.cs" /> 318 <Compile Include="Nca\ModelCreation\INcaModelCreator.cs" /> 319 <Compile Include="Nca\ModelCreation\NcaModelCreator.cs" /> 309 320 <Compile Include="Nca\NcaAlgorithm.cs" /> 310 321 <Compile Include="Nca\NcaClassificationSolution.cs" /> 322 <Compile Include="Nca\NcaGradientCalculator.cs" /> 311 323 <Compile Include="Nca\NcaModel.cs" /> 324 <Compile Include="Nca\SolutionCreation\INcaSolutionCreator.cs" /> 325 <Compile Include="Nca\SolutionCreation\NcaSolutionCreator.cs" /> 312 326 <Compile Include="NearestNeighbour\NearestNeighbourClassification.cs" /> 313 327 <Compile Include="NearestNeighbour\NearestNeighbourClassificationSolution.cs" /> -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IDataAnalysisAlgorithm.cs ¶
r8137 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IGaussianProcessModel.cs ¶
r8982 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IGaussianProcessSolution.cs ¶
r8371 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INcaClassificationSolution.cs ¶
r8471 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INcaModel.cs ¶
r8471 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INearestNeighbourClassificationSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INearestNeighbourModel.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INearestNeighbourRegressionSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INeuralNetworkClassificationSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INeuralNetworkEnsembleClassificationSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INeuralNetworkEnsembleModel.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INeuralNetworkEnsembleRegressionSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INeuralNetworkModel.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INeuralNetworkRegressionSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IRandomForestClassificationSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IRandomForestModel.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IRandomForestRegressionSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/ISupportVectorMachineModel.cs ¶
r8609 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/ISupportVectorMachineSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/INcaInitializer.cs ¶
r8471 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 24 24 25 25 namespace HeuristicLab.Algorithms.DataAnalysis { 26 public interface IN CAInitializer : IItem{26 public interface INcaInitializer : IOperator { 27 27 /// <summary> 28 28 /// Calculates an initial projection for the NCA to start from. … … 30 30 /// <param name="data">The problem data that contains the AllowedInputVariables and TrainingIndices.</param> 31 31 /// <param name="dimensions">The amount of columns in the matrix</param> 32 /// <returns> A flat representation of a matrix that is read row-wise and contains AllowedInputVariables * TrainingIndices numbers.</returns>33 double[ ] Initialize(IClassificationProblemData data, int dimensions);32 /// <returns>The matrix that projects the input variables into a lower dimensional space.</returns> 33 double[,] Initialize(IClassificationProblemData data, int dimensions); 34 34 } 35 35 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/LdaInitializer.cs ¶
r8471 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using System.Linq; 24 23 using HeuristicLab.Common; … … 30 29 [Item("LDA", "Initializes the matrix by performing a linear discriminant analysis.")] 31 30 [StorableClass] 32 public class L DAInitializer : Item, INCAInitializer {31 public class LdaInitializer : NcaInitializer { 33 32 34 33 [StorableConstructor] 35 protected L DAInitializer(bool deserializing) : base(deserializing) { }36 protected L DAInitializer(LDAInitializer original, Cloner cloner) : base(original, cloner) { }37 public L DAInitializer() : base() { }34 protected LdaInitializer(bool deserializing) : base(deserializing) { } 35 protected LdaInitializer(LdaInitializer original, Cloner cloner) : base(original, cloner) { } 36 public LdaInitializer() : base() { } 38 37 39 38 public override IDeepCloneable Clone(Cloner cloner) { 40 return new L DAInitializer(this, cloner);39 return new LdaInitializer(this, cloner); 41 40 } 42 41 43 public double[] Initialize(IClassificationProblemData data, int dimensions) {42 public override double[,] Initialize(IClassificationProblemData data, int dimensions) { 44 43 var instances = data.TrainingIndices.Count(); 45 44 var attributes = data.AllowedInputVariables.Count(); 46 45 47 var ldaDs = new double[instances, attributes + 1]; 48 int row, col = 0; 49 foreach (var variable in data.AllowedInputVariables) { 50 row = 0; 51 foreach (var value in data.Dataset.GetDoubleValues(variable, data.TrainingIndices)) { 52 ldaDs[row, col] = value; 53 row++; 54 } 55 col++; 56 } 57 row = 0; 58 var uniqueClasses = new Dictionary<double, int>(); 59 foreach (var label in data.Dataset.GetDoubleValues(data.TargetVariable, data.TrainingIndices)) { 60 if (!uniqueClasses.ContainsKey(label)) 61 uniqueClasses[label] = uniqueClasses.Count; 62 ldaDs[row++, attributes] = label; 63 } 64 for (row = 0; row < instances; row++) 46 var ldaDs = AlglibUtil.PrepareInputMatrix(data.Dataset, 47 data.AllowedInputVariables.Concat(data.TargetVariable.ToEnumerable()), 48 data.TrainingIndices); 49 50 // map class values to sequential natural numbers (required by alglib) 51 var uniqueClasses = data.Dataset.GetDoubleValues(data.TargetVariable, data.TrainingIndices) 52 .Distinct() 53 .Select((v, i) => new { v, i }) 54 .ToDictionary(x => x.v, x => x.i); 55 56 for (int row = 0; row < instances; row++) 65 57 ldaDs[row, attributes] = uniqueClasses[ldaDs[row, attributes]]; 66 58 … … 69 61 alglib.fisherldan(ldaDs, instances, attributes, uniqueClasses.Count, out info, out matrix); 70 62 71 var result = new double[attributes * dimensions]; 72 for (int i = 0; i < attributes; i++) 73 for (int j = 0; j < dimensions; j++) 74 result[i * dimensions + j] = matrix[i, j]; 75 76 return result; 63 return matrix; 77 64 } 78 65 -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/PcaInitializer.cs ¶
r8471 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 29 29 [Item("PCA", "Initializes the matrix by performing a principal components analysis.")] 30 30 [StorableClass] 31 public sealed class P CAInitializer : Item, INCAInitializer {31 public sealed class PcaInitializer : NcaInitializer { 32 32 33 33 [StorableConstructor] 34 private P CAInitializer(bool deserializing) : base(deserializing) { }35 private P CAInitializer(PCAInitializer original, Cloner cloner) : base(original, cloner) { }36 public P CAInitializer() : base() { }34 private PcaInitializer(bool deserializing) : base(deserializing) { } 35 private PcaInitializer(PcaInitializer original, Cloner cloner) : base(original, cloner) { } 36 public PcaInitializer() : base() { } 37 37 38 38 public override IDeepCloneable Clone(Cloner cloner) { 39 return new P CAInitializer(this, cloner);39 return new PcaInitializer(this, cloner); 40 40 } 41 41 42 public double[] Initialize(IClassificationProblemData data, int dimensions) {42 public override double[,] Initialize(IClassificationProblemData data, int dimensions) { 43 43 var instances = data.TrainingIndices.Count(); 44 44 var attributes = data.AllowedInputVariables.Count(); 45 45 46 var pcaDs = new double[instances, attributes]; 47 int col = 0; 48 foreach (var variable in data.AllowedInputVariables) { 49 int row = 0; 50 foreach (var value in data.Dataset.GetDoubleValues(variable, data.TrainingIndices)) { 51 pcaDs[row, col] = value; 52 row++; 53 } 54 col++; 55 } 46 var pcaDs = AlglibUtil.PrepareInputMatrix(data.Dataset, data.AllowedInputVariables, data.TrainingIndices); 56 47 57 48 int info; … … 60 51 alglib.pcabuildbasis(pcaDs, instances, attributes, out info, out varianceValues, out matrix); 61 52 62 var result = new double[attributes * dimensions]; 63 for (int i = 0; i < attributes; i++) 64 for (int j = 0; j < dimensions; j++) 65 result[i * dimensions + j] = matrix[i, j]; 66 67 return result; 53 return matrix; 68 54 } 69 55 -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Initialization/RandomInitializer.cs ¶
r8471 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab. Data;25 using HeuristicLab.Optimization; 26 26 using HeuristicLab.Parameters; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 using HeuristicLab.Problems.DataAnalysis; 29 using HeuristicLab.Random;30 29 31 30 namespace HeuristicLab.Algorithms.DataAnalysis { 32 31 [Item("Random", "Initializes the matrix randomly.")] 33 32 [StorableClass] 34 public class RandomInitializer : ParameterizedNamedItem, INCAInitializer { 35 private IValueParameter<IntValue> RandomParameter { 36 get { return (IValueParameter<IntValue>)Parameters["Seed"]; } 37 } 38 private IValueParameter<BoolValue> SetSeedRandomlyParameter { 39 get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 40 } 41 42 public int Seed { 43 get { return RandomParameter.Value.Value; } 44 set { RandomParameter.Value.Value = value; } 45 } 46 47 public bool SetSeedRandomly { 48 get { return SetSeedRandomlyParameter.Value.Value; } 49 set { SetSeedRandomlyParameter.Value.Value = value; } 33 public sealed class RandomInitializer : NcaInitializer, IStochasticOperator { 34 public ILookupParameter<IRandom> RandomParameter { 35 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 50 36 } 51 37 52 38 [StorableConstructor] 53 pr otectedRandomInitializer(bool deserializing) : base(deserializing) { }54 pr otectedRandomInitializer(RandomInitializer original, Cloner cloner) : base(original, cloner) { }39 private RandomInitializer(bool deserializing) : base(deserializing) { } 40 private RandomInitializer(RandomInitializer original, Cloner cloner) : base(original, cloner) { } 55 41 public RandomInitializer() 56 42 : base() { 57 Parameters.Add(new ValueParameter<IntValue>("Seed", "The seed for the random number generator.", new IntValue(0))); 58 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "Whether the seed should be randomized for each call.", new BoolValue(true))); 43 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 59 44 } 60 45 … … 63 48 } 64 49 65 public double[] Initialize(IClassificationProblemData data, int dimensions) { 66 var instances = data.TrainingIndices.Count(); 50 public override double[,] Initialize(IClassificationProblemData data, int dimensions) { 67 51 var attributes = data.AllowedInputVariables.Count(); 68 52 69 var random = new MersenneTwister(); 70 if (SetSeedRandomly) Seed = random.Next(); 71 random.Reset(Seed); 72 73 var range = data.AllowedInputVariables.Select(x => data.Dataset.GetDoubleValues(x).Max() - data.Dataset.GetDoubleValues(x).Min()).ToArray(); 74 var matrix = new double[attributes * dimensions]; 75 for (int i = 0; i < matrix.Length; i++) 76 matrix[i] = random.NextDouble() / range[i / dimensions]; 53 var random = RandomParameter.ActualValue; 54 var matrix = new double[attributes, dimensions]; 55 for (int i = 0; i < attributes; i++) 56 for (int j = 0; j < dimensions; j++) 57 matrix[i, j] = random.NextDouble(); 77 58 78 59 return matrix; -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Matrix.cs ¶
r8681 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/NcaAlgorithm.cs ¶
r8681 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 using System.Threading; 26 using HeuristicLab.Analysis; 24 using HeuristicLab.Algorithms.GradientDescent; 27 25 using HeuristicLab.Common; 28 26 using HeuristicLab.Core; 29 27 using HeuristicLab.Data; 28 using HeuristicLab.Operators; 30 29 using HeuristicLab.Optimization; 31 30 using HeuristicLab.Parameters; … … 33 32 using HeuristicLab.PluginInfrastructure; 34 33 using HeuristicLab.Problems.DataAnalysis; 34 using HeuristicLab.Random; 35 35 36 36 namespace HeuristicLab.Algorithms.DataAnalysis { 37 internal delegate void Reporter(double quality, double[] coefficients, double[] gradients);38 37 /// <summary> 39 38 /// Neighborhood Components Analysis … … 46 45 [Creatable("Data Analysis")] 47 46 [StorableClass] 48 public sealed class NcaAlgorithm : FixedDataAnalysisAlgorithm<IClassificationProblem> { 47 public sealed class NcaAlgorithm : EngineAlgorithm { 48 #region Parameter Names 49 private const string SeedParameterName = "Seed"; 50 private const string SetSeedRandomlyParameterName = "SetSeedRandomly"; 51 private const string KParameterName = "K"; 52 private const string DimensionsParameterName = "Dimensions"; 53 private const string InitializationParameterName = "Initialization"; 54 private const string NeighborSamplesParameterName = "NeighborSamples"; 55 private const string IterationsParameterName = "Iterations"; 56 private const string RegularizationParameterName = "Regularization"; 57 private const string NcaModelCreatorParameterName = "NcaModelCreator"; 58 private const string NcaSolutionCreatorParameterName = "NcaSolutionCreator"; 59 private const string ApproximateGradientsParameterName = "ApproximateGradients"; 60 private const string NcaMatrixParameterName = "NcaMatrix"; 61 private const string NcaMatrixGradientsParameterName = "NcaMatrixGradients"; 62 private const string QualityParameterName = "Quality"; 63 #endregion 64 65 public override Type ProblemType { get { return typeof(IClassificationProblem); } } 66 public new IClassificationProblem Problem { 67 get { return (IClassificationProblem)base.Problem; } 68 set { base.Problem = value; } 69 } 70 49 71 #region Parameter Properties 72 public IValueParameter<IntValue> SeedParameter { 73 get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; } 74 } 75 public IValueParameter<BoolValue> SetSeedRandomlyParameter { 76 get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; } 77 } 50 78 public IFixedValueParameter<IntValue> KParameter { 51 get { return (IFixedValueParameter<IntValue>)Parameters[ "K"]; }79 get { return (IFixedValueParameter<IntValue>)Parameters[KParameterName]; } 52 80 } 53 81 public IFixedValueParameter<IntValue> DimensionsParameter { 54 get { return (IFixedValueParameter<IntValue>)Parameters[ "Dimensions"]; }55 } 56 public IConstrainedValueParameter<IN CAInitializer> InitializationParameter {57 get { return (IConstrainedValueParameter<IN CAInitializer>)Parameters["Initialization"]; }82 get { return (IFixedValueParameter<IntValue>)Parameters[DimensionsParameterName]; } 83 } 84 public IConstrainedValueParameter<INcaInitializer> InitializationParameter { 85 get { return (IConstrainedValueParameter<INcaInitializer>)Parameters[InitializationParameterName]; } 58 86 } 59 87 public IFixedValueParameter<IntValue> NeighborSamplesParameter { 60 get { return (IFixedValueParameter<IntValue>)Parameters[ "NeighborSamples"]; }88 get { return (IFixedValueParameter<IntValue>)Parameters[NeighborSamplesParameterName]; } 61 89 } 62 90 public IFixedValueParameter<IntValue> IterationsParameter { 63 get { return (IFixedValueParameter<IntValue>)Parameters[ "Iterations"]; }91 get { return (IFixedValueParameter<IntValue>)Parameters[IterationsParameterName]; } 64 92 } 65 93 public IFixedValueParameter<DoubleValue> RegularizationParameter { 66 get { return (IFixedValueParameter<DoubleValue>)Parameters["Regularization"]; } 94 get { return (IFixedValueParameter<DoubleValue>)Parameters[RegularizationParameterName]; } 95 } 96 public IValueParameter<BoolValue> ApproximateGradientsParameter { 97 get { return (IValueParameter<BoolValue>)Parameters[ApproximateGradientsParameterName]; } 98 } 99 public IValueParameter<INcaModelCreator> NcaModelCreatorParameter { 100 get { return (IValueParameter<INcaModelCreator>)Parameters[NcaModelCreatorParameterName]; } 101 } 102 public IValueParameter<INcaSolutionCreator> NcaSolutionCreatorParameter { 103 get { return (IValueParameter<INcaSolutionCreator>)Parameters[NcaSolutionCreatorParameterName]; } 67 104 } 68 105 #endregion 69 106 70 107 #region Properties 108 public int Seed { 109 get { return SeedParameter.Value.Value; } 110 set { SeedParameter.Value.Value = value; } 111 } 112 public bool SetSeedRandomly { 113 get { return SetSeedRandomlyParameter.Value.Value; } 114 set { SetSeedRandomlyParameter.Value.Value = value; } 115 } 71 116 public int K { 72 117 get { return KParameter.Value.Value; } … … 88 133 get { return RegularizationParameter.Value.Value; } 89 134 set { RegularizationParameter.Value.Value = value; } 135 } 136 public INcaModelCreator NcaModelCreator { 137 get { return NcaModelCreatorParameter.Value; } 138 set { NcaModelCreatorParameter.Value = value; } 139 } 140 public INcaSolutionCreator NcaSolutionCreator { 141 get { return NcaSolutionCreatorParameter.Value; } 142 set { NcaSolutionCreatorParameter.Value = value; } 90 143 } 91 144 #endregion … … 96 149 public NcaAlgorithm() 97 150 : base() { 98 Parameters.Add(new FixedValueParameter<IntValue>("K", "The K for the nearest neighbor.", new IntValue(3))); 99 Parameters.Add(new FixedValueParameter<IntValue>("Dimensions", "The number of dimensions that NCA should reduce the data to.", new IntValue(2))); 100 Parameters.Add(new ConstrainedValueParameter<INCAInitializer>("Initialization", "Which method should be used to initialize the matrix. Typically LDA (linear discriminant analysis) should provide a good estimate.")); 101 Parameters.Add(new FixedValueParameter<IntValue>("NeighborSamples", "How many of the neighbors should be sampled in order to speed up the calculation. This should be at least the value of k and at most the number of training instances minus one.", new IntValue(60))); 102 Parameters.Add(new FixedValueParameter<IntValue>("Iterations", "How many iterations the conjugate gradient (CG) method should be allowed to perform. The method might still terminate earlier if a local optima has already been reached.", new IntValue(50))); 103 Parameters.Add(new FixedValueParameter<DoubleValue>("Regularization", "A non-negative paramter which can be set to increase generalization and avoid overfitting. If set to 0 the algorithm is similar to NCA as proposed by Goldberger et al.", new DoubleValue(0))); 104 105 INCAInitializer defaultInitializer = null; 106 foreach (var initializer in ApplicationManager.Manager.GetInstances<INCAInitializer>().OrderBy(x => x.ItemName)) { 107 if (initializer is LDAInitializer) defaultInitializer = initializer; 151 Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The seed of the random number generator.", new IntValue(0))); 152 Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "A boolean flag that indicates whether the seed should be randomly reset each time the algorithm is run.", new BoolValue(true))); 153 Parameters.Add(new FixedValueParameter<IntValue>(KParameterName, "The K for the nearest neighbor.", new IntValue(3))); 154 Parameters.Add(new FixedValueParameter<IntValue>(DimensionsParameterName, "The number of dimensions that NCA should reduce the data to.", new IntValue(2))); 155 Parameters.Add(new ConstrainedValueParameter<INcaInitializer>(InitializationParameterName, "Which method should be used to initialize the matrix. Typically LDA (linear discriminant analysis) should provide a good estimate.")); 156 Parameters.Add(new FixedValueParameter<IntValue>(NeighborSamplesParameterName, "How many of the neighbors should be sampled in order to speed up the calculation. This should be at least the value of k and at most the number of training instances minus one will be used.", new IntValue(60))); 157 Parameters.Add(new FixedValueParameter<IntValue>(IterationsParameterName, "How many iterations the conjugate gradient (CG) method should be allowed to perform. The method might still terminate earlier if a local optima has already been reached.", new IntValue(50))); 158 Parameters.Add(new FixedValueParameter<DoubleValue>(RegularizationParameterName, "A non-negative paramter which can be set to increase generalization and avoid overfitting. If set to 0 the algorithm is similar to NCA as proposed by Goldberger et al.", new DoubleValue(0))); 159 Parameters.Add(new ValueParameter<INcaModelCreator>(NcaModelCreatorParameterName, "Creates an NCA model out of the matrix.", new NcaModelCreator())); 160 Parameters.Add(new ValueParameter<INcaSolutionCreator>(NcaSolutionCreatorParameterName, "Creates an NCA solution given a model and some data.", new NcaSolutionCreator())); 161 Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "True if the gradient should be approximated otherwise they are computed exactly.", new BoolValue())); 162 163 NcaSolutionCreatorParameter.Hidden = true; 164 ApproximateGradientsParameter.Hidden = true; 165 166 INcaInitializer defaultInitializer = null; 167 foreach (var initializer in ApplicationManager.Manager.GetInstances<INcaInitializer>().OrderBy(x => x.ItemName)) { 168 if (initializer is LdaInitializer) defaultInitializer = initializer; 108 169 InitializationParameter.ValidValues.Add(initializer); 109 170 } 110 171 if (defaultInitializer != null) InitializationParameter.Value = defaultInitializer; 111 172 173 var randomCreator = new RandomCreator(); 174 var ncaInitializer = new Placeholder(); 175 var bfgsInitializer = new LbfgsInitializer(); 176 var makeStep = new LbfgsMakeStep(); 177 var branch = new ConditionalBranch(); 178 var gradientCalculator = new NcaGradientCalculator(); 179 var modelCreator = new Placeholder(); 180 var updateResults = new LbfgsUpdateResults(); 181 var analyzer = new LbfgsAnalyzer(); 182 var finalModelCreator = new Placeholder(); 183 var finalAnalyzer = new LbfgsAnalyzer(); 184 var solutionCreator = new Placeholder(); 185 186 OperatorGraph.InitialOperator = randomCreator; 187 randomCreator.SeedParameter.ActualName = SeedParameterName; 188 randomCreator.SeedParameter.Value = null; 189 randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName; 190 randomCreator.SetSeedRandomlyParameter.Value = null; 191 randomCreator.Successor = ncaInitializer; 192 193 ncaInitializer.Name = "(NcaInitializer)"; 194 ncaInitializer.OperatorParameter.ActualName = InitializationParameterName; 195 ncaInitializer.Successor = bfgsInitializer; 196 197 bfgsInitializer.IterationsParameter.ActualName = IterationsParameterName; 198 bfgsInitializer.PointParameter.ActualName = NcaMatrixParameterName; 199 bfgsInitializer.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 200 bfgsInitializer.Successor = makeStep; 201 202 makeStep.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 203 makeStep.PointParameter.ActualName = NcaMatrixParameterName; 204 makeStep.Successor = branch; 205 206 branch.ConditionParameter.ActualName = makeStep.TerminationCriterionParameter.Name; 207 branch.FalseBranch = gradientCalculator; 208 branch.TrueBranch = finalModelCreator; 209 210 gradientCalculator.Successor = modelCreator; 211 212 modelCreator.OperatorParameter.ActualName = NcaModelCreatorParameterName; 213 modelCreator.Successor = updateResults; 214 215 updateResults.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 216 updateResults.QualityParameter.ActualName = QualityParameterName; 217 updateResults.QualityGradientsParameter.ActualName = NcaMatrixGradientsParameterName; 218 updateResults.ApproximateGradientsParameter.ActualName = ApproximateGradientsParameterName; 219 updateResults.Successor = analyzer; 220 221 analyzer.QualityParameter.ActualName = QualityParameterName; 222 analyzer.PointParameter.ActualName = NcaMatrixParameterName; 223 analyzer.QualityGradientsParameter.ActualName = NcaMatrixGradientsParameterName; 224 analyzer.StateParameter.ActualName = bfgsInitializer.StateParameter.Name; 225 analyzer.PointsTableParameter.ActualName = "Matrix table"; 226 analyzer.QualityGradientsTableParameter.ActualName = "Gradients table"; 227 analyzer.QualitiesTableParameter.ActualName = "Qualities"; 228 analyzer.Successor = makeStep; 229 230 finalModelCreator.OperatorParameter.ActualName = NcaModelCreatorParameterName; 231 finalModelCreator.Successor = finalAnalyzer; 232 233 finalAnalyzer.QualityParameter.ActualName = QualityParameterName; 234 finalAnalyzer.PointParameter.ActualName = NcaMatrixParameterName; 235 finalAnalyzer.QualityGradientsParameter.ActualName = NcaMatrixGradientsParameterName; 236 finalAnalyzer.PointsTableParameter.ActualName = analyzer.PointsTableParameter.ActualName; 237 finalAnalyzer.QualityGradientsTableParameter.ActualName = analyzer.QualityGradientsTableParameter.ActualName; 238 finalAnalyzer.QualitiesTableParameter.ActualName = analyzer.QualitiesTableParameter.ActualName; 239 finalAnalyzer.Successor = solutionCreator; 240 241 solutionCreator.OperatorParameter.ActualName = NcaSolutionCreatorParameterName; 242 112 243 Problem = new ClassificationProblem(); 113 244 } … … 117 248 } 118 249 119 [StorableHook(HookType.AfterDeserialization)]120 private void AfterDeserialization() {121 if (!Parameters.ContainsKey("Regularization")) {122 Parameters.Add(new FixedValueParameter<DoubleValue>("Regularization", "A non-negative paramter which can be set to increase generalization and avoid overfitting. If set to 0 the algorithm is similar to NCA as proposed by Goldberger et al.", new DoubleValue(0)));123 }124 }125 126 250 public override void Prepare() { 127 251 if (Problem != null) base.Prepare(); 128 252 } 129 130 protected override void Run() {131 var initializer = InitializationParameter.Value;132 133 var clonedProblem = (IClassificationProblemData)Problem.ProblemData.Clone();134 var model = Train(clonedProblem, K, Dimensions, NeighborSamples, Regularization, Iterations, initializer.Initialize(clonedProblem, Dimensions), ReportQuality, CancellationToken.None);135 var solution = model.CreateClassificationSolution(clonedProblem);136 if (!Results.ContainsKey("ClassificationSolution"))137 Results.Add(new Result("ClassificationSolution", "The classification solution.", solution));138 else Results["ClassificationSolution"].Value = solution;139 }140 141 public static INcaClassificationSolution CreateClassificationSolution(IClassificationProblemData data, int k, int dimensions, int neighborSamples, double regularization, int iterations, INCAInitializer initializer) {142 var clonedProblem = (IClassificationProblemData)data.Clone();143 var model = Train(clonedProblem, k, dimensions, neighborSamples, regularization, iterations, initializer);144 return model.CreateClassificationSolution(clonedProblem);145 }146 147 public static INcaModel Train(IClassificationProblemData problemData, int k, int dimensions, int neighborSamples, double regularization, int iterations, INCAInitializer initializer) {148 return Train(problemData, k, dimensions, neighborSamples, regularization, iterations, initializer.Initialize(problemData, dimensions), null, CancellationToken.None);149 }150 151 public static INcaModel Train(IClassificationProblemData problemData, int k, int neighborSamples, double regularization, int iterations, double[,] initalMatrix) {152 var matrix = new double[initalMatrix.Length];153 for (int i = 0; i < initalMatrix.GetLength(0); i++)154 for (int j = 0; j < initalMatrix.GetLength(1); j++)155 matrix[i * initalMatrix.GetLength(1) + j] = initalMatrix[i, j];156 return Train(problemData, k, initalMatrix.GetLength(1), neighborSamples, regularization, iterations, matrix, null, CancellationToken.None);157 }158 159 private static INcaModel Train(IClassificationProblemData data, int k, int dimensions, int neighborSamples, double regularization, int iterations, double[] matrix, Reporter reporter, CancellationToken cancellation) {160 var scaling = new Scaling(data.Dataset, data.AllowedInputVariables, data.TrainingIndices);161 var scaledData = AlglibUtil.PrepareAndScaleInputMatrix(data.Dataset, data.AllowedInputVariables, data.TrainingIndices, scaling);162 var classes = data.Dataset.GetDoubleValues(data.TargetVariable, data.TrainingIndices).ToArray();163 var attributes = scaledData.GetLength(1);164 165 alglib.mincgstate state;166 alglib.mincgreport rep;167 alglib.mincgcreate(matrix, out state);168 alglib.mincgsetcond(state, 0, 0, 0, iterations);169 alglib.mincgsetxrep(state, true);170 //alglib.mincgsetgradientcheck(state, 0.01);171 int neighborSampleSize = neighborSamples;172 Optimize(state, scaledData, classes, dimensions, neighborSampleSize, regularization, cancellation, reporter);173 alglib.mincgresults(state, out matrix, out rep);174 if (rep.terminationtype == -7) throw new InvalidOperationException("Gradient verification failed.");175 176 var transformationMatrix = new double[attributes, dimensions];177 var counter = 0;178 for (var i = 0; i < attributes; i++)179 for (var j = 0; j < dimensions; j++)180 transformationMatrix[i, j] = matrix[counter++];181 182 return new NcaModel(k, transformationMatrix, data.Dataset, data.TrainingIndices, data.TargetVariable, data.AllowedInputVariables, scaling, data.ClassValues.ToArray());183 }184 185 private static void Optimize(alglib.mincgstate state, double[,] data, double[] classes, int dimensions, int neighborSampleSize, double lambda, CancellationToken cancellation, Reporter reporter) {186 while (alglib.mincgiteration(state)) {187 if (cancellation.IsCancellationRequested) break;188 if (state.needfg) {189 Gradient(state.x, ref state.innerobj.f, state.innerobj.g, data, classes, dimensions, neighborSampleSize, lambda);190 continue;191 }192 if (state.innerobj.xupdated) {193 if (reporter != null)194 reporter(state.innerobj.f, state.innerobj.x, state.innerobj.g);195 continue;196 }197 throw new InvalidOperationException("Neighborhood Components Analysis: Error in Optimize() (some derivatives were not provided?)");198 }199 }200 201 private static void Gradient(double[] A, ref double func, double[] grad, double[,] data, double[] classes, int dimensions, int neighborSampleSize, double lambda) {202 var instances = data.GetLength(0);203 var attributes = data.GetLength(1);204 205 var AMatrix = new Matrix(A, A.Length / dimensions, dimensions);206 207 alglib.sparsematrix probabilities;208 alglib.sparsecreate(instances, instances, out probabilities);209 var transformedDistances = new Dictionary<int, double>(instances);210 for (int i = 0; i < instances; i++) {211 var iVector = new Matrix(GetRow(data, i), data.GetLength(1));212 for (int k = 0; k < instances; k++) {213 if (k == i) {214 transformedDistances.Remove(k);215 continue;216 }217 var kVector = new Matrix(GetRow(data, k));218 transformedDistances[k] = Math.Exp(-iVector.Multiply(AMatrix).Subtract(kVector.Multiply(AMatrix)).SumOfSquares());219 }220 var normalization = transformedDistances.Sum(x => x.Value);221 if (normalization <= 0) continue;222 foreach (var s in transformedDistances.Where(x => x.Value > 0).OrderByDescending(x => x.Value).Take(neighborSampleSize)) {223 alglib.sparseset(probabilities, i, s.Key, s.Value / normalization);224 }225 }226 alglib.sparseconverttocrs(probabilities); // needed to enumerate in order (top-down and left-right)227 228 int t0 = 0, t1 = 0, r, c;229 double val;230 var pi = new double[instances];231 while (alglib.sparseenumerate(probabilities, ref t0, ref t1, out r, out c, out val)) {232 if (classes[r].IsAlmost(classes[c])) {233 pi[r] += val;234 }235 }236 237 var innerSum = new double[attributes, attributes];238 while (alglib.sparseenumerate(probabilities, ref t0, ref t1, out r, out c, out val)) {239 var vector = new Matrix(GetRow(data, r)).Subtract(new Matrix(GetRow(data, c)));240 vector.OuterProduct(vector).Multiply(val * pi[r]).AddTo(innerSum);241 242 if (classes[r].IsAlmost(classes[c])) {243 vector.OuterProduct(vector).Multiply(-val).AddTo(innerSum);244 }245 }246 247 func = -pi.Sum() + lambda * AMatrix.SumOfSquares();248 249 r = 0;250 var newGrad = AMatrix.Multiply(-2.0).Transpose().Multiply(new Matrix(innerSum)).Transpose();251 foreach (var g in newGrad) {252 grad[r] = g + lambda * 2 * A[r];253 r++;254 }255 }256 257 private void ReportQuality(double func, double[] coefficients, double[] gradients) {258 var instances = Problem.ProblemData.TrainingIndices.Count();259 DataTable qualities;260 if (!Results.ContainsKey("Optimization")) {261 qualities = new DataTable("Optimization");262 qualities.Rows.Add(new DataRow("Quality", string.Empty));263 Results.Add(new Result("Optimization", qualities));264 } else qualities = (DataTable)Results["Optimization"].Value;265 qualities.Rows["Quality"].Values.Add(-func / instances);266 267 string[] attributNames = Problem.ProblemData.AllowedInputVariables.ToArray();268 if (gradients != null) {269 DataTable grads;270 if (!Results.ContainsKey("Gradients")) {271 grads = new DataTable("Gradients");272 for (int i = 0; i < gradients.Length; i++)273 grads.Rows.Add(new DataRow(attributNames[i / Dimensions] + "-" + (i % Dimensions), string.Empty));274 Results.Add(new Result("Gradients", grads));275 } else grads = (DataTable)Results["Gradients"].Value;276 for (int i = 0; i < gradients.Length; i++)277 grads.Rows[attributNames[i / Dimensions] + "-" + (i % Dimensions)].Values.Add(gradients[i]);278 }279 280 if (!Results.ContainsKey("Quality")) {281 Results.Add(new Result("Quality", new DoubleValue(-func / instances)));282 } else ((DoubleValue)Results["Quality"].Value).Value = -func / instances;283 284 var attributes = attributNames.Length;285 var transformationMatrix = new double[attributes, Dimensions];286 var counter = 0;287 for (var i = 0; i < attributes; i++)288 for (var j = 0; j < Dimensions; j++)289 transformationMatrix[i, j] = coefficients[counter++];290 291 var scaling = new Scaling(Problem.ProblemData.Dataset, attributNames, Problem.ProblemData.TrainingIndices);292 var model = new NcaModel(K, transformationMatrix, Problem.ProblemData.Dataset, Problem.ProblemData.TrainingIndices, Problem.ProblemData.TargetVariable, attributNames, scaling, Problem.ProblemData.ClassValues.ToArray());293 294 IClassificationSolution solution = model.CreateClassificationSolution(Problem.ProblemData);295 if (!Results.ContainsKey("ClassificationSolution")) {296 Results.Add(new Result("ClassificationSolution", solution));297 } else {298 Results["ClassificationSolution"].Value = solution;299 }300 }301 302 private static IEnumerable<double> GetRow(double[,] data, int row) {303 for (int i = 0; i < data.GetLength(1); i++)304 yield return data[row, i];305 }306 307 253 } 308 254 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/NcaClassificationSolution.cs ¶
r8723 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/NcaModel.cs ¶
r8528 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 33 33 34 34 [Storable] 35 private Scaling scaling;36 [Storable]37 35 private double[,] transformationMatrix; 38 36 public double[,] TransformationMatrix { … … 52 50 protected NcaModel(NcaModel original, Cloner cloner) 53 51 : base(original, cloner) { 54 this.scaling = cloner.Clone(original.scaling);55 52 this.transformationMatrix = (double[,])original.transformationMatrix.Clone(); 56 53 this.allowedInputVariables = (string[])original.allowedInputVariables.Clone(); … … 59 56 this.classValues = (double[])original.classValues.Clone(); 60 57 } 61 public NcaModel(int k, double[,] transformationMatrix, Dataset dataset, IEnumerable<int> rows, string targetVariable, IEnumerable<string> allowedInputVariables, Scaling scaling,double[] classValues) {58 public NcaModel(int k, double[,] transformationMatrix, Dataset dataset, IEnumerable<int> rows, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues) { 62 59 Name = ItemName; 63 60 Description = ItemDescription; 64 this.scaling = scaling;65 61 this.transformationMatrix = (double[,])transformationMatrix.Clone(); 66 62 this.allowedInputVariables = allowedInputVariables.ToArray(); … … 90 86 91 87 public double[,] Reduce(Dataset dataset, IEnumerable<int> rows) { 92 var scaledData = AlglibUtil.PrepareAndScaleInputMatrix(dataset, allowedInputVariables, rows, scaling); 88 var data = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 89 93 90 var targets = dataset.GetDoubleValues(targetVariable, rows).ToArray(); 94 var result = new double[ scaledData.GetLength(0), transformationMatrix.GetLength(1) + 1];95 for (int i = 0; i < scaledData.GetLength(0); i++)96 for (int j = 0; j < scaledData.GetLength(1); j++) {91 var result = new double[data.GetLength(0), transformationMatrix.GetLength(1) + 1]; 92 for (int i = 0; i < data.GetLength(0); i++) 93 for (int j = 0; j < data.GetLength(1); j++) { 97 94 for (int x = 0; x < transformationMatrix.GetLength(1); x++) { 98 result[i, x] += scaledData[i, j] * transformationMatrix[j, x];95 result[i, x] += data[i, j] * transformationMatrix[j, x]; 99 96 } 100 97 result[i, transformationMatrix.GetLength(1)] = targets[i]; -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Plugin.cs.frame ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 /// Plugin class for HeuristicLab.Algorithms.DataAnalysis plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Algorithms.DataAnalysis", "Provides wrappers for data analysis algorithms implemented in external libraries (linear regression, linear discriminant analysis, k-means clustering, support vector classification and regression)", "3.4. 3.$WCREV$")]28 [Plugin("HeuristicLab.Algorithms.DataAnalysis", "Provides wrappers for data analysis algorithms implemented in external libraries (linear regression, linear discriminant analysis, k-means clustering, support vector classification and regression)", "3.4.5.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Algorithms.DataAnalysis-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB", "3. 6.0")]30 [PluginDependency("HeuristicLab.ALGLIB", "3.7.0")] 31 31 [PluginDependency("HeuristicLab.Algorithms.GradientDescent", "3.3")] 32 32 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/DataAnalysisSolutionEvaluationView.Designer.cs ¶
r7967 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/DataAnalysisSolutionEvaluationView.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/DoubleLimitView.Designer.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/DoubleLimitView.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj ¶
r9119 r10553 93 93 </PropertyGroup> 94 94 <ItemGroup> 95 <Reference Include="ALGLIB-3.6.0"> 96 <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.6.0.dll</HintPath> 95 <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 96 <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath> 97 <Private>False</Private> 97 98 </Reference> 98 99 <Reference Include="HeuristicLab.Analysis-3.3"> … … 222 223 <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon> 223 224 </Compile> 224 <Compile Include="FeatureCorrelation\EnhancedStringConvertibleMatrixView.cs">225 <SubType>UserControl</SubType>226 </Compile>227 <Compile Include="FeatureCorrelation\EnhancedStringConvertibleMatrixView.Designer.cs">228 <DependentUpon>EnhancedStringConvertibleMatrixView.cs</DependentUpon>229 </Compile>230 225 <Compile Include="FeatureCorrelation\FeatureCorrelationCalculator.cs" /> 231 226 <Compile Include="FeatureCorrelation\FeatureCorrelationView.cs"> … … 235 230 <DependentUpon>FeatureCorrelationView.cs</DependentUpon> 236 231 </Compile> 232 <Compile Include="MenuItems\ShrinkDataAnalysisRunsMenuItem.cs" /> 237 233 <Compile Include="Plugin.cs" /> 238 234 <Compile Include="ProblemDataView.cs"> -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/CreateEnsembleMenuItem.cs ¶
r7738 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Windows.Forms; 26 using HeuristicLab.Core; 25 using HeuristicLab.Common; 27 26 using HeuristicLab.MainForm; 27 using HeuristicLab.MainForm.WindowsForms; 28 28 using HeuristicLab.Optimization; 29 using HeuristicLab.Optimization.Views; 29 30 using HeuristicLab.Optimizer; 30 31 31 namespace HeuristicLab.Problems.DataAnalysis. MenuItems {32 namespace HeuristicLab.Problems.DataAnalysis.Views { 32 33 internal class CreateEnsembleMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider { 33 34 public override string Name { … … 35 36 } 36 37 public override IEnumerable<string> Structure { 37 get { return new string[] { "&Edit" }; }38 get { return new string[] { "&Edit", "&Data Analysis" }; } 38 39 } 39 40 public override int Position { 40 get { return 2500; }41 get { return 5100; } 41 42 } 42 43 public override string ToolTipText { … … 49 50 protected override void OnActiveViewChanged(object sender, EventArgs e) { 50 51 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 51 if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked) {52 var optimizer = activeView.Content as IOptimizer;53 ToolStripItem.Enabled = GetDataAnalysisResults(optimizer).Any();54 } else {55 ToolStripItem.Enabled = false;56 }52 ToolStripItem.Enabled = GetDataAnalysisResults(activeView).Any(); 53 } 54 protected override void OnViewChanged(object sender, EventArgs e) { 55 base.OnViewChanged(sender, e); 56 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 57 ToolStripItem.Enabled = GetDataAnalysisResults(activeView).Any(); 57 58 } 58 59 59 60 public override void Execute() { 60 61 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 61 if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked) { 62 var optimizer = activeView.Content as IOptimizer; 63 var solutionGroups = from pair in GetDataAnalysisResults(optimizer) 64 group pair.Value by pair.Key into g 65 select g; 66 foreach (var group in solutionGroups) { 67 // check if all solutions in the group are either only regression or only classification solutions 68 if (group.All(s => s is IRegressionSolution)) { 69 // show all regression ensembles 70 // clone problemdata (N.B. this assumes all solutions are based on the same problem data!) 71 var problemData = (RegressionProblemData)group 72 .OfType<IRegressionSolution>() 73 .First() 74 .ProblemData.Clone(); 75 var ensemble = new RegressionEnsembleSolution(problemData); 76 ensemble.Name = group.Key + " ensemble"; 77 var nestedSolutions = group.OfType<RegressionEnsembleSolution>().SelectMany(e => e.RegressionSolutions); 78 var solutions = group.Where(s => !(s is RegressionEnsembleSolution)).OfType<IRegressionSolution>(); 79 ensemble.AddRegressionSolutions(nestedSolutions.Concat(solutions)); 80 MainFormManager.MainForm.ShowContent(ensemble); 81 } else if (group.All(s => s is IClassificationSolution)) { 82 // show all classification ensembles 83 var problemData = (ClassificationProblemData)group 84 .OfType<IClassificationSolution>() 85 .First() 86 .ProblemData.Clone(); 87 var ensemble = new ClassificationEnsembleSolution(Enumerable.Empty<IClassificationModel>(), problemData); 88 ensemble.Name = group.Key + " ensemble"; 89 var nestedSolutions = group.OfType<ClassificationEnsembleSolution>().SelectMany(e => e.ClassificationSolutions); 90 var solutions = group.Where(s => !(s is ClassificationEnsembleSolution)).OfType<IClassificationSolution>(); 91 ensemble.AddClassificationSolutions(nestedSolutions.Concat(solutions)); 92 MainFormManager.MainForm.ShowContent(ensemble); 93 } 62 var solutionGroups = from pair in GetDataAnalysisResults(activeView) 63 group pair.Value by pair.Key into g 64 select g; 65 foreach (var group in solutionGroups) { 66 // check if all solutions in the group are either only regression or only classification solutions 67 if (group.All(s => s is IRegressionSolution)) { 68 // show all regression ensembles 69 // N.B. this assumes all solutions are based on the same problem data! 70 // the problem data is not cloned because the individual solutions were already cloned 71 var problemData = group.OfType<IRegressionSolution>().First().ProblemData; 72 var ensemble = new RegressionEnsembleSolution(problemData); 73 ensemble.Name = group.Key + " ensemble"; 74 var nestedSolutions = group.OfType<RegressionEnsembleSolution>().SelectMany(e => e.RegressionSolutions); 75 var solutions = group.Where(s => !(s is RegressionEnsembleSolution)).OfType<IRegressionSolution>(); 76 ensemble.AddRegressionSolutions(nestedSolutions.Concat(solutions)); 77 MainFormManager.MainForm.ShowContent(ensemble); 78 } else if (group.All(s => s is IClassificationSolution)) { 79 // show all classification ensembles 80 // N.B. this assumes all solutions are based on the same problem data! 81 // the problem data is not cloned because the individual solutions were already cloned 82 var problemData = (ClassificationProblemData)group.OfType<IClassificationSolution>().First().ProblemData; 83 var ensemble = new ClassificationEnsembleSolution(Enumerable.Empty<IClassificationModel>(), problemData); 84 ensemble.Name = group.Key + " ensemble"; 85 var nestedSolutions = group.OfType<ClassificationEnsembleSolution>().SelectMany(e => e.ClassificationSolutions); 86 var solutions = group.Where(s => !(s is ClassificationEnsembleSolution)).OfType<IClassificationSolution>(); 87 ensemble.AddClassificationSolutions(nestedSolutions.Concat(solutions)); 88 MainFormManager.MainForm.ShowContent(ensemble); 94 89 } 95 90 } 96 91 } 97 92 98 private IEnumerable<KeyValuePair<string, IItem>> GetDataAnalysisResults(IOptimizer optimizer) { 99 var allResults = from r in optimizer.Runs 93 private IEnumerable<KeyValuePair<string, IDataAnalysisSolution>> GetDataAnalysisResults(IContentView view) { 94 var empty = Enumerable.Empty<KeyValuePair<string, IDataAnalysisSolution>>(); 95 if (view == null) return empty; 96 if (view.Content == null) return empty; 97 if (view.Locked) return empty; 98 99 var optimizer = view.Content as IOptimizer; 100 if (optimizer != null) return GetDataAnalysisResults(optimizer.Runs); 101 102 RunCollectionBubbleChartView bubbleChart; 103 var viewHost = view as ViewHost; 104 if (viewHost != null) 105 bubbleChart = viewHost.ActiveView as RunCollectionBubbleChartView; 106 else bubbleChart = view as RunCollectionBubbleChartView; 107 if (bubbleChart != null && bubbleChart.SelectedRuns.Any()) return GetDataAnalysisResults(bubbleChart.SelectedRuns); 108 109 return empty; 110 } 111 112 private IEnumerable<KeyValuePair<string, IDataAnalysisSolution>> GetDataAnalysisResults(IEnumerable<IRun> runs) { 113 var cloner = new Cloner(); 114 var allResults = from r in runs 100 115 select r.Results; 101 116 return from r in allResults 102 117 from result in r 103 let s = result.Valueas IDataAnalysisSolution118 let s = cloner.Clone(result.Value) as IDataAnalysisSolution 104 119 where s != null 105 select result;120 select new KeyValuePair<string, IDataAnalysisSolution>(result.Key, s); 106 121 } 107 122 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/Plugin.cs.frame ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis.Views { 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "Provides views for base classes for data analysis tasks.", "3.4. 3.$WCREV$")]28 [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "Provides views for base classes for data analysis tasks.", "3.4.5.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Views-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB", "3. 6.0")]30 [PluginDependency("HeuristicLab.ALGLIB", "3.7.0")] 31 31 [PluginDependency("HeuristicLab.Analysis", "3.3")] 32 32 [PluginDependency("HeuristicLab.Collections", "3.3")] … … 42 42 [PluginDependency("HeuristicLab.Optimization.Views","3.3")] 43 43 [PluginDependency("HeuristicLab.Optimizer", "3.3")] 44 [PluginDependency("HeuristicLab.Persistence", "3.3")] 44 45 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 45 46 [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")] -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataView.Designer.cs ¶
r8924 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataView.cs ¶
r8833 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 76 76 var values = variableValues.ElementAt(i); 77 77 IList clonedValues = null; 78 if (values is List<double>)78 if (values is IList<double>) 79 79 clonedValues = new List<double>(values.Cast<double>()); 80 else if (values is List<string>)80 else if (values is IList<string>) 81 81 clonedValues = new List<string>(values.Cast<string>()); 82 else if (values is List<DateTime>)82 else if (values is IList<DateTime>) 83 83 clonedValues = new List<DateTime>(values.Cast<DateTime>()); 84 84 else { 85 85 this.variableNames = new List<string>(); 86 86 this.variableValues = new Dictionary<string, IList>(); 87 throw new ArgumentException("The variable values must be of type List<double>, List<string> orList<DateTime>");87 throw new ArgumentException("The variable values must be of type IList<double>, IList<string> or IList<DateTime>"); 88 88 } 89 89 this.variableValues.Add(this.variableNames[i], clonedValues); … … 191 191 throw new ArgumentException("The variable " + variableName + " does not exist in the dataset."); 192 192 List<double> values = list as List<double>; 193 if (values == null) throw new ArgumentException("The varia lbe " + variableName + " is not a double variable.");193 if (values == null) throw new ArgumentException("The variable " + variableName + " is not a double variable."); 194 194 195 195 return rows.Select(index => values[index]); -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/DatasetExtensions.cs ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/DoubleLimit.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj ¶
r9119 r10553 93 93 </PropertyGroup> 94 94 <ItemGroup> 95 <Reference Include="ALGLIB-3.6.0"> 96 <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.6.0.dll</HintPath> 97 <Private>False</Private> 98 </Reference> 99 <Reference Include="HeuristicLab.ALGLIB-3.6.0"> 100 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.ALGLIB-3.6.0.dll</HintPath> 95 <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 96 <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath> 101 97 <Private>False</Private> 102 98 </Reference> … … 194 190 </Compile> 195 191 <Compile Include="Interfaces\Classification\IDiscriminantFunctionThresholdCalculator.cs" /> 192 <Compile Include="Interfaces\IDataAnalysisSolutionExporter.cs" /> 196 193 <Compile Include="Interfaces\IDependencyCalculator.cs" /> 197 194 <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs"> … … 214 211 <Compile Include="OnlineCalculators\MatthewsCorrelationCoefficientCalculator.cs" /> 215 212 <Compile Include="OnlineCalculators\OnlineBoundedMeanSquaredErrorCalculator.cs" /> 213 <Compile Include="OnlineCalculators\OnlineCovarianceCalculator.cs" /> 216 214 <Compile Include="OnlineCalculators\OnlineDirectionalSymmetryCalculator.cs" /> 217 215 <Compile Include="OnlineCalculators\OnlineMaxAbsoluteErrorCalculator.cs" /> … … 246 244 <Compile Include="Interfaces\Regression\IRegressionProblemData.cs" /> 247 245 <Compile Include="Interfaces\Regression\IRegressionSolution.cs" /> 248 <Compile Include="OnlineCalculators\OnlineCovarianceCalcualtor.cs" />249 246 <Compile Include="OnlineCalculators\OnlineMeanAbsolutePercentageErrorCalculator.cs" /> 250 247 <Compile Include="OnlineCalculators\OnlineMeanAndVarianceCalculator.cs" /> -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisModel.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblem.cs ¶
r7823 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs ¶
r8139 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 43 43 44 44 event EventHandler Changed; 45 46 void AdjustProblemDataProperties(IDataAnalysisProblemData problemData); 45 47 } 46 48 } -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisSolution.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDependencyCalculator.cs ¶
r8861 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IOnlineCalculator.cs ¶
r8113 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/AutoCorrelationCalculator.cs ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/NormalizedGiniCalculator.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineAccuracyCalculator.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineBoundedMeanSquaredErrorCalculator.cs ¶
r8664 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineDirectionalSymmetryCalculator.cs ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineLinearScalingParameterCalculator.cs ¶
r8113 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMaxAbsoluteErrorCalculator.cs ¶
r7678 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsoluteErrorCalculator.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsolutePercentageErrorCalculator.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAndVarianceCalculator.cs ¶
r8966 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanErrorCalculator.cs ¶
r7272 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanSquaredErrorCalculator.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineNormalizedMeanSquaredErrorCalculator.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlinePearsonsRSquaredCalculator.cs ¶
r7259 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineTheilsUStatisticCalculator.cs ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineWeightedDirectionalSymmetryCalculator.cs ¶
r8798 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
TabularUnified branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Plugin.cs.frame ¶
r8581 r10553 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis { 28 [Plugin("HeuristicLab.Problems.DataAnalysis","Provides base classes for data analysis tasks.", "3.4. 3.$WCREV$")]28 [Plugin("HeuristicLab.Problems.DataAnalysis","Provides base classes for data analysis tasks.", "3.4.5.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB","3. 6")]30 [PluginDependency("HeuristicLab.ALGLIB","3.7.0")] 31 31 [PluginDependency("HeuristicLab.Collections", "3.3")] 32 32 [PluginDependency("HeuristicLab.Common", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.