Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/NcaModel.cs
- Timestamp:
- 03/18/19 17:24:30 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/stable/HeuristicLab.Algorithms.DataAnalysis/3.4 merged eligible /branches/1721-RandomForestPersistence/HeuristicLab.Algorithms.DataAnalysis/3.4 10321-10322 /branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4 13329-15286 /branches/Benchmarking/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 6917-7005 /branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4 9070-13099 /branches/CloningRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Algorithms.DataAnalysis/3.4 5815-6180 /branches/DataAnalysis/HeuristicLab.Algorithms.DataAnalysis/3.4 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.Algorithms.DataAnalysis/3.4 10085-11101 /branches/GP.Grammar.Editor/HeuristicLab.Algorithms.DataAnalysis/3.4 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Algorithms.DataAnalysis/3.4 5060 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 11570-12508 /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4 11130-12721 /branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Algorithms.DataAnalysis/3.4 13819-14091 /branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4 8116-8789 /branches/LogResidualEvaluator/HeuristicLab.Algorithms.DataAnalysis/3.4 10202-10483 /branches/NET40/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 5138-5162 /branches/ParallelEngine/HeuristicLab.Algorithms.DataAnalysis/3.4 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Algorithms.DataAnalysis/3.4 7773-7810 /branches/QAPAlgorithms/HeuristicLab.Algorithms.DataAnalysis/3.4 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Algorithms.DataAnalysis/3.4 6828 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Algorithms.DataAnalysis/3.4 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.DataAnalysis/3.4 5370-5682 /branches/Trunk/HeuristicLab.Algorithms.DataAnalysis/3.4 6829-6865 /branches/VNS/HeuristicLab.Algorithms.DataAnalysis/3.4 5594-5752 /branches/Weighted TSNE/3.4 15451-15531 /branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4 5959-6341 /branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4 14232-14825 /trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 13331-15681
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/NcaModel.cs
r12509 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 30 30 [Item("NCA Model", "")] 31 31 [StorableClass] 32 public class NcaModel : NamedItem, INcaModel { 32 public class NcaModel : ClassificationModel, INcaModel { 33 public override IEnumerable<string> VariablesUsedForPrediction { 34 get { return allowedInputVariables; } 35 } 33 36 34 37 [Storable] … … 39 42 [Storable] 40 43 private string[] allowedInputVariables; 41 [Storable]42 private string targetVariable;43 44 [Storable] 44 45 private INearestNeighbourModel nnModel; … … 52 53 this.transformationMatrix = (double[,])original.transformationMatrix.Clone(); 53 54 this.allowedInputVariables = (string[])original.allowedInputVariables.Clone(); 54 this.targetVariable = original.targetVariable;55 55 this.nnModel = cloner.Clone(original.nnModel); 56 56 this.classValues = (double[])original.classValues.Clone(); 57 57 } 58 public NcaModel(int k, double[,] transformationMatrix, IDataset 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 : base(targetVariable) { 59 60 Name = ItemName; 60 61 Description = ItemDescription; 61 62 this.transformationMatrix = (double[,])transformationMatrix.Clone(); 62 63 this.allowedInputVariables = allowedInputVariables.ToArray(); 63 this.targetVariable = targetVariable;64 64 this.classValues = (double[])classValues.Clone(); 65 65 … … 72 72 } 73 73 74 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {74 public override 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)); 77 77 } 78 78 79 public INcaClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {80 return new NcaClassificationSolution( new ClassificationProblemData(problemData), this);79 public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 80 return new NcaClassificationSolution(this, new ClassificationProblemData(problemData)); 81 81 } 82 82 83 I ClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {84 return CreateClassificationSolution(problemData);83 INcaClassificationSolution INcaModel.CreateClassificationSolution(IClassificationProblemData problemData) { 84 return new NcaClassificationSolution(this, new ClassificationProblemData(problemData)); 85 85 } 86 86 87 87 public double[,] Reduce(IDataset dataset, IEnumerable<int> rows) { 88 var data = AlglibUtil.PrepareInputMatrix(dataset,allowedInputVariables, rows);88 var data = dataset.ToArray(allowedInputVariables, rows); 89 89 90 var targets = dataset.GetDoubleValues( targetVariable, rows).ToArray();90 var targets = dataset.GetDoubleValues(TargetVariable, rows).ToArray(); 91 91 var result = new double[data.GetLength(0), transformationMatrix.GetLength(1) + 1]; 92 92 for (int i = 0; i < data.GetLength(0); i++) … … 104 104 .Range(0, transformationMatrix.GetLength(1)) 105 105 .Select(x => "X" + x.ToString()) 106 .Concat( targetVariable.ToEnumerable()),106 .Concat(TargetVariable.ToEnumerable()), 107 107 Reduce(dataset, rows)); 108 108 }
Note: See TracChangeset
for help on using the changeset viewer.