Changeset 11571 for branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis
- Timestamp:
- 11/24/14 15:16:59 (10 years ago)
- Location:
- branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4
- Files:
-
- 2 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs
r11171 r11571 117 117 this.x = original.x; 118 118 } 119 public GaussianProcessModel( Dataset ds, string targetVariable, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows,119 public GaussianProcessModel(IDataset ds, string targetVariable, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows, 120 120 IEnumerable<double> hyp, IMeanFunction meanFunction, ICovarianceFunction covarianceFunction) 121 121 : base() { … … 141 141 } 142 142 143 private void CalculateModel( Dataset ds, IEnumerable<int> rows) {143 private void CalculateModel(IDataset ds, IEnumerable<int> rows) { 144 144 inputScaling = new Scaling(ds, allowedInputVariables, rows); 145 145 x = AlglibUtil.PrepareAndScaleInputMatrix(ds, allowedInputVariables, rows, inputScaling); … … 245 245 246 246 #region IRegressionModel Members 247 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {247 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 248 248 return GetEstimatedValuesHelper(dataset, rows); 249 249 } … … 257 257 258 258 259 private IEnumerable<double> GetEstimatedValuesHelper( Dataset dataset, IEnumerable<int> rows) {259 private IEnumerable<double> GetEstimatedValuesHelper(IDataset dataset, IEnumerable<int> rows) { 260 260 var newX = AlglibUtil.PrepareAndScaleInputMatrix(dataset, allowedInputVariables, rows, inputScaling); 261 261 int newN = newX.GetLength(0); … … 277 277 } 278 278 279 public IEnumerable<double> GetEstimatedVariance( Dataset dataset, IEnumerable<int> rows) {279 public IEnumerable<double> GetEstimatedVariance(IDataset dataset, IEnumerable<int> rows) { 280 280 var newX = AlglibUtil.PrepareAndScaleInputMatrix(dataset, allowedInputVariables, rows, inputScaling); 281 281 int newN = newX.GetLength(0); -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
r11317 r11571 263 263 <Compile Include="RandomForest\RandomForestRegressionSolution.cs" /> 264 264 <Compile Include="RandomForest\RandomForestUtil.cs" /> 265 <Compile Include="SupportVectorMachine\SupportVectorParameterTuningEvaluator.cs" /> 266 <Compile Include="SupportVectorMachine\SupportVectorParameterTuningProblem.cs" /> 265 267 <Compile Include="SupportVectorMachine\SupportVectorClassification.cs" /> 266 268 <Compile Include="SupportVectorMachine\SupportVectorClassificationSolution.cs" /> -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IGaussianProcessModel.cs
r11171 r11571 34 34 double[] HyperparameterGradients { get; } 35 35 36 IEnumerable<double> GetEstimatedVariance( Dataset ds, IEnumerable<int> rows);36 IEnumerable<double> GetEstimatedVariance(IDataset ds, IEnumerable<int> rows); 37 37 void FixParameters(); 38 38 } -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/INcaModel.cs
r11171 r11571 27 27 new INcaClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData); 28 28 29 double[,] Reduce( Dataset dataset, IEnumerable<int> rows);29 double[,] Reduce(IDataset dataset, IEnumerable<int> rows); 30 30 } 31 31 } -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/AlglibUtil.cs
r11171 r11571 26 26 namespace HeuristicLab.Algorithms.DataAnalysis { 27 27 public static class AlglibUtil { 28 public static double[,] PrepareInputMatrix( Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows) {28 public static double[,] PrepareInputMatrix(IDataset dataset, IEnumerable<string> variables, IEnumerable<int> rows) { 29 29 List<string> variablesList = variables.ToList(); 30 30 List<int> rowsList = rows.ToList(); … … 45 45 return matrix; 46 46 } 47 public static double[,] PrepareAndScaleInputMatrix( Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows, Scaling scaling) {47 public static double[,] PrepareAndScaleInputMatrix(IDataset dataset, IEnumerable<string> variables, IEnumerable<int> rows, Scaling scaling) { 48 48 List<string> variablesList = variables.ToList(); 49 49 List<int> rowsList = rows.ToList(); -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearDiscriminantAnalysis.cs
r11171 r11571 65 65 66 66 public static IClassificationSolution CreateLinearDiscriminantAnalysisSolution(IClassificationProblemData problemData) { 67 Datasetdataset = problemData.Dataset;67 var dataset = problemData.Dataset; 68 68 string targetVariable = problemData.TargetVariable; 69 69 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs
r11171 r11571 69 69 70 70 public static ISymbolicRegressionSolution CreateLinearRegressionSolution(IRegressionProblemData problemData, out double rmsError, out double cvRmsError) { 71 Datasetdataset = problemData.Dataset;71 var dataset = problemData.Dataset; 72 72 string targetVariable = problemData.TargetVariable; 73 73 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitClassification.cs
r11171 r11571 66 66 67 67 public static IClassificationSolution CreateLogitClassificationSolution(IClassificationProblemData problemData, out double rmsError, out double relClassError) { 68 Datasetdataset = problemData.Dataset;68 var dataset = problemData.Dataset; 69 69 string targetVariable = problemData.TargetVariable; 70 70 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitModel.cs
r11171 r11571 82 82 } 83 83 84 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {84 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 85 85 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 86 86 -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/Scaling.cs
r11171 r11571 41 41 scalingParameters.Add(pair.Key, Tuple.Create(pair.Value.Item1, pair.Value.Item2)); 42 42 } 43 public Scaling( Dataset ds, IEnumerable<string> variables, IEnumerable<int> rows) {43 public Scaling(IDataset ds, IEnumerable<string> variables, IEnumerable<int> rows) { 44 44 foreach (var variable in variables) { 45 45 var values = ds.GetDoubleValues(variable, rows); … … 54 54 } 55 55 56 public IEnumerable<double> GetScaledValues( Dataset ds, string variable, IEnumerable<int> rows) {56 public IEnumerable<double> GetScaledValues(IDataset ds, string variable, IEnumerable<int> rows) { 57 57 double min = scalingParameters[variable].Item1; 58 58 double max = scalingParameters[variable].Item2; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/NcaModel.cs
r11171 r11571 56 56 this.classValues = (double[])original.classValues.Clone(); 57 57 } 58 public NcaModel(int k, double[,] transformationMatrix, Dataset dataset, IEnumerable<int> rows, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues) {58 public NcaModel(int k, double[,] transformationMatrix, IDataset dataset, IEnumerable<int> rows, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues) { 59 59 Name = ItemName; 60 60 Description = ItemDescription; … … 72 72 } 73 73 74 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {74 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 75 75 var ds = ReduceDataset(dataset, rows); 76 76 return nnModel.GetEstimatedClassValues(ds, Enumerable.Range(0, ds.Rows)); … … 85 85 } 86 86 87 public double[,] Reduce( Dataset dataset, IEnumerable<int> rows) {87 public double[,] Reduce(IDataset dataset, IEnumerable<int> rows) { 88 88 var data = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 89 89 … … 100 100 } 101 101 102 public Dataset ReduceDataset( Dataset dataset, IEnumerable<int> rows) {102 public Dataset ReduceDataset(IDataset dataset, IEnumerable<int> rows) { 103 103 return new Dataset(Enumerable 104 104 .Range(0, transformationMatrix.GetLength(1)) -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs
r11171 r11571 96 96 this.classValues = (double[])original.classValues.Clone(); 97 97 } 98 public NearestNeighbourModel( Dataset dataset, IEnumerable<int> rows, int k, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null) {98 public NearestNeighbourModel(IDataset dataset, IEnumerable<int> rows, int k, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null) { 99 99 Name = ItemName; 100 100 Description = ItemDescription; … … 135 135 } 136 136 137 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {137 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 138 138 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 139 139 … … 163 163 } 164 164 165 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {165 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 166 166 if (classValues == null) throw new InvalidOperationException("No class values are defined."); 167 167 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassification.cs
r11171 r11571 179 179 public static IClassificationSolution CreateNeuralNetworkClassificationSolution(IClassificationProblemData problemData, int nLayers, int nHiddenNodes1, int nHiddenNodes2, double decay, int restarts, 180 180 out double rmsError, out double avgRelError, out double relClassError) { 181 Datasetdataset = problemData.Dataset;181 var dataset = problemData.Dataset; 182 182 string targetVariable = problemData.TargetVariable; 183 183 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassification.cs
r11171 r11571 124 124 public NeuralNetworkEnsembleClassification() 125 125 : base() { 126 126 var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { 127 127 (IntValue)new IntValue(0).AsReadOnly(), 128 128 (IntValue)new IntValue(1).AsReadOnly(), … … 165 165 public static IClassificationSolution CreateNeuralNetworkEnsembleClassificationSolution(IClassificationProblemData problemData, int ensembleSize, int nLayers, int nHiddenNodes1, int nHiddenNodes2, double decay, int restarts, 166 166 out double rmsError, out double avgRelError, out double relClassError) { 167 Datasetdataset = problemData.Dataset;167 var dataset = problemData.Dataset; 168 168 string targetVariable = problemData.TargetVariable; 169 169 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleModel.cs
r11171 r11571 86 86 } 87 87 88 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {88 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 89 89 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 90 90 … … 103 103 } 104 104 105 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {105 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 106 106 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 107 107 -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegression.cs
r11171 r11571 124 124 public NeuralNetworkEnsembleRegression() 125 125 : base() { 126 126 var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { 127 127 (IntValue)new IntValue(0).AsReadOnly(), 128 128 (IntValue)new IntValue(1).AsReadOnly(), … … 164 164 public static IRegressionSolution CreateNeuralNetworkEnsembleRegressionSolution(IRegressionProblemData problemData, int ensembleSize, int nLayers, int nHiddenNodes1, int nHiddenNodes2, double decay, int restarts, 165 165 out double rmsError, out double avgRelError) { 166 Datasetdataset = problemData.Dataset;166 var dataset = problemData.Dataset; 167 167 string targetVariable = problemData.TargetVariable; 168 168 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs
r11171 r11571 94 94 } 95 95 96 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {96 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 97 97 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 98 98 … … 111 111 } 112 112 113 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {113 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 114 114 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 115 115 -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegression.cs
r11171 r11571 180 180 public static IRegressionSolution CreateNeuralNetworkRegressionSolution(IRegressionProblemData problemData, int nLayers, int nHiddenNodes1, int nHiddenNodes2, double decay, int restarts, 181 181 out double rmsError, out double avgRelError) { 182 Datasetdataset = problemData.Dataset;182 var dataset = problemData.Dataset; 183 183 string targetVariable = problemData.TargetVariable; 184 184 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs
r11343 r11571 129 129 } 130 130 131 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {131 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 132 132 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, AllowedInputVariables, rows); 133 133 AssertInputMatrix(inputData); … … 147 147 } 148 148 149 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {149 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 150 150 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, AllowedInputVariables, rows); 151 151 AssertInputMatrix(inputData); … … 205 205 outOfBagRmsError = rep.oobrmserror; 206 206 207 return new RandomForestModel(dForest, seed, problemData,nTrees, r, m);207 return new RandomForestModel(dForest, seed, problemData, nTrees, r, m); 208 208 } 209 209 … … 242 242 outOfBagRelClassificationError = rep.oobrelclserror; 243 243 244 return new RandomForestModel(dForest, seed, problemData,nTrees, r, m, classValues);244 return new RandomForestModel(dForest, seed, problemData, nTrees, r, m, classValues); 245 245 } 246 246 -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestUtil.cs
r11445 r11571 90 90 91 91 public static class RandomForestUtil { 92 private static readonly object locker = new object();93 94 92 private static void CrossValidate(IRegressionProblemData problemData, Tuple<IEnumerable<int>, IEnumerable<int>>[] partitions, int nTrees, double r, double m, int seed, out double avgTestMse) { 95 93 avgTestMse = 0; … … 132 130 } 133 131 134 // grid search without cross-validation since in the case of random forests, the out-of-bag estimate is unbiased 132 /// <summary> 133 /// Grid search without crossvalidation (since for random forests the out-of-bag estimate is unbiased) 134 /// </summary> 135 /// <param name="problemData">The regression problem data</param> 136 /// <param name="parameterRanges">The ranges for each parameter in the grid search</param> 137 /// <param name="seed">The random seed (required by the random forest model)</param> 138 /// <param name="maxDegreeOfParallelism">The maximum allowed number of threads (to parallelize the grid search)</param> 135 139 public static RFParameter GridSearch(IRegressionProblemData problemData, Dictionary<string, IEnumerable<double>> parameterRanges, int seed = 12345, int maxDegreeOfParallelism = 1) { 136 140 var setters = parameterRanges.Keys.Select(GenerateSetter).ToList(); … … 139 143 RFParameter bestParameters = new RFParameter(); 140 144 145 var locker = new object(); 141 146 Parallel.ForEach(crossProduct, new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism }, parameterCombination => { 142 147 var parameterValues = parameterCombination.ToList(); … … 156 161 } 157 162 163 /// <summary> 164 /// Grid search without crossvalidation (since for random forests the out-of-bag estimate is unbiased) 165 /// </summary> 166 /// <param name="problemData">The classification problem data</param> 167 /// <param name="parameterRanges">The ranges for each parameter in the grid search</param> 168 /// <param name="seed">The random seed (required by the random forest model)</param> 169 /// <param name="maxDegreeOfParallelism">The maximum allowed number of threads (to parallelize the grid search)</param> 158 170 public static RFParameter GridSearch(IClassificationProblemData problemData, Dictionary<string, IEnumerable<double>> parameterRanges, int seed = 12345, int maxDegreeOfParallelism = 1) { 159 171 var setters = parameterRanges.Keys.Select(GenerateSetter).ToList(); … … 163 175 RFParameter bestParameters = new RFParameter(); 164 176 177 var locker = new object(); 165 178 Parallel.ForEach(crossProduct, new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism }, parameterCombination => { 166 179 var parameterValues = parameterCombination.ToList(); … … 181 194 } 182 195 196 /// <summary> 197 /// Grid search with crossvalidation 198 /// </summary> 199 /// <param name="problemData">The regression problem data</param> 200 /// <param name="numberOfFolds">The number of folds for crossvalidation</param> 201 /// <param name="shuffleFolds">Specifies whether the folds should be shuffled</param> 202 /// <param name="parameterRanges">The ranges for each parameter in the grid search</param> 203 /// <param name="seed">The random seed (required by the random forest model)</param> 204 /// <param name="maxDegreeOfParallelism">The maximum allowed number of threads (to parallelize the grid search)</param> 205 /// <returns>The best parameter values found by the grid search</returns> 183 206 public static RFParameter GridSearch(IRegressionProblemData problemData, int numberOfFolds, bool shuffleFolds, Dictionary<string, IEnumerable<double>> parameterRanges, int seed = 12345, int maxDegreeOfParallelism = 1) { 184 207 DoubleValue mse = new DoubleValue(Double.MaxValue); … … 189 212 var crossProduct = parameterRanges.Values.CartesianProduct(); 190 213 214 var locker = new object(); 191 215 Parallel.ForEach(crossProduct, new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism }, parameterCombination => { 192 216 var parameterValues = parameterCombination.ToList(); … … 208 232 } 209 233 234 /// <summary> 235 /// Grid search with crossvalidation 236 /// </summary> 237 /// <param name="problemData">The classification problem data</param> 238 /// <param name="numberOfFolds">The number of folds for crossvalidation</param> 239 /// <param name="shuffleFolds">Specifies whether the folds should be shuffled</param> 240 /// <param name="parameterRanges">The ranges for each parameter in the grid search</param> 241 /// <param name="seed">The random seed (for shuffling)</param> 242 /// <param name="maxDegreeOfParallelism">The maximum allowed number of threads (to parallelize the grid search)</param> 210 243 public static RFParameter GridSearch(IClassificationProblemData problemData, int numberOfFolds, bool shuffleFolds, Dictionary<string, IEnumerable<double>> parameterRanges, int seed = 12345, int maxDegreeOfParallelism = 1) { 211 244 DoubleValue accuracy = new DoubleValue(0); … … 216 249 var partitions = GenerateRandomForestPartitions(problemData, numberOfFolds, shuffleFolds); 217 250 251 var locker = new object(); 218 252 Parallel.ForEach(crossProduct, new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism }, parameterCombination => { 219 253 var parameterValues = parameterCombination.ToList(); -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorClassification.cs
r11340 r11571 149 149 public static SupportVectorClassificationSolution CreateSupportVectorClassificationSolution(IClassificationProblemData problemData, IEnumerable<string> allowedInputVariables, 150 150 int svmType, int kernelType, double cost, double nu, double gamma, int degree, out double trainingAccuracy, out double testAccuracy, out int nSv) { 151 Datasetdataset = problemData.Dataset;151 var dataset = problemData.Dataset; 152 152 string targetVariable = problemData.TargetVariable; 153 153 IEnumerable<int> rows = problemData.TrainingIndices; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs
r11171 r11571 120 120 121 121 #region IRegressionModel Members 122 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {122 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 123 123 return GetEstimatedValuesHelper(dataset, rows); 124 124 } … … 132 132 133 133 #region IClassificationModel Members 134 public IEnumerable<double> GetEstimatedClassValues( Dataset dataset, IEnumerable<int> rows) {134 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 135 135 if (classValues == null) throw new NotSupportedException(); 136 136 // return the original class value instead of the predicted value of the model … … 159 159 } 160 160 #endregion 161 private IEnumerable<double> GetEstimatedValuesHelper( Dataset dataset, IEnumerable<int> rows) {161 private IEnumerable<double> GetEstimatedValuesHelper(IDataset dataset, IEnumerable<int> rows) { 162 162 // calculate predictions for the currently requested rows 163 163 svm_problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, targetVariable, allowedInputVariables, rows); -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs
r11542 r11571 40 40 /// <param name="rowIndices">The rows of the dataset that should be contained in the resulting SVM-problem</param> 41 41 /// <returns>A problem data type that can be used to train a support vector machine.</returns> 42 public static svm_problem CreateSvmProblem( Dataset dataset, string targetVariable, IEnumerable<string> inputVariables, IEnumerable<int> rowIndices) {42 public static svm_problem CreateSvmProblem(IDataset dataset, string targetVariable, IEnumerable<string> inputVariables, IEnumerable<int> rowIndices) { 43 43 double[] targetVector = dataset.GetDoubleValues(targetVariable, rowIndices).ToArray(); 44 44 svm_node[][] nodes = new svm_node[targetVector.Length][]; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs
r11171 r11571 152 152 string svmType, string kernelType, double cost, double nu, double gamma, double epsilon, int degree, 153 153 out double trainingR2, out double testR2, out int nSv) { 154 Datasetdataset = problemData.Dataset;154 var dataset = problemData.Dataset; 155 155 string targetVariable = problemData.TargetVariable; 156 156 IEnumerable<int> rows = problemData.TrainingIndices; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClustering.cs
r11171 r11571 83 83 84 84 public static KMeansClusteringSolution CreateKMeansSolution(IClusteringProblemData problemData, int k, int restarts) { 85 Datasetdataset = problemData.Dataset;85 var dataset = problemData.Dataset; 86 86 IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables; 87 87 IEnumerable<int> rows = problemData.TrainingIndices; -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClusteringModel.cs
r11171 r11571 81 81 82 82 83 public IEnumerable<int> GetClusterValues( Dataset dataset, IEnumerable<int> rows) {83 public IEnumerable<int> GetClusterValues(IDataset dataset, IEnumerable<int> rows) { 84 84 return KMeansClusteringUtil.FindClosestCenters(centers, dataset, allowedInputVariables, rows); 85 85 } -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClusteringUtil.cs
r11171 r11571 27 27 namespace HeuristicLab.Algorithms.DataAnalysis { 28 28 public static class KMeansClusteringUtil { 29 public static IEnumerable<int> FindClosestCenters(IEnumerable<double[]> centers, Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows) {29 public static IEnumerable<int> FindClosestCenters(IEnumerable<double[]> centers, IDataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows) { 30 30 int nRows = rows.Count(); 31 31 int nCols = allowedInputVariables.Count(); … … 58 58 } 59 59 60 public static double CalculateIntraClusterSumOfSquares(KMeansClusteringModel model, Dataset dataset, IEnumerable<int> rows) {60 public static double CalculateIntraClusterSumOfSquares(KMeansClusteringModel model, IDataset dataset, IEnumerable<int> rows) { 61 61 List<int> clusterValues = model.GetClusterValues(dataset, rows).ToList(); 62 62 List<string> allowedInputVariables = model.AllowedInputVariables.ToList();
Note: See TracChangeset
for help on using the changeset viewer.