Changeset 18027 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourRegression.cs
- Timestamp:
- 07/20/21 18:13:55 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis merged: 17931,17934,17942,17979
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Algorithms.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis/3.4 merged: 17931,17934,17942,17979
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourRegression.cs
r17180 r18027 41 41 private const string NearestNeighbourRegressionModelResultName = "Nearest neighbour regression solution"; 42 42 private const string WeightsParameterName = "Weights"; 43 private const string SelfMatchParameterName = "SelfMatch";44 43 45 44 #region parameter properties 46 45 public IFixedValueParameter<IntValue> KParameter { 47 46 get { return (IFixedValueParameter<IntValue>)Parameters[KParameterName]; } 48 }49 public IFixedValueParameter<BoolValue> SelfMatchParameter {50 get { return (IFixedValueParameter<BoolValue>)Parameters[SelfMatchParameterName]; }51 47 } 52 48 public IValueParameter<DoubleArray> WeightsParameter { … … 61 57 else KParameter.Value.Value = value; 62 58 } 63 }64 public bool SelfMatch {65 get { return SelfMatchParameter.Value.Value; }66 set { SelfMatchParameter.Value.Value = value; }67 59 } 68 60 public DoubleArray Weights { … … 81 73 Parameters.Add(new FixedValueParameter<IntValue>(KParameterName, "The number of nearest neighbours to consider for regression.", new IntValue(3))); 82 74 Parameters.Add(new OptionalValueParameter<DoubleArray>(WeightsParameterName, "Optional: use weights to specify individual scaling values for all features. If not set the weights are calculated automatically (each feature is scaled to unit variance)")); 83 Parameters.Add(new FixedValueParameter<BoolValue>(SelfMatchParameterName, "Should we use equal points for classification?", new BoolValue(false)));84 75 Problem = new RegressionProblem(); 85 76 } … … 91 82 if (!Parameters.ContainsKey(WeightsParameterName)) { 92 83 Parameters.Add(new OptionalValueParameter<DoubleArray>(WeightsParameterName, "Optional: use weights to specify individual scaling values for all features. If not set the weights are calculated automatically (each feature is scaled to unit variance)")); 93 }94 if (!Parameters.ContainsKey(SelfMatchParameterName)) {95 Parameters.Add(new FixedValueParameter<BoolValue>(SelfMatchParameterName, "Should we use equal points for classification?", new BoolValue(false)));96 84 } 97 85 #endregion … … 106 94 double[] weights = null; 107 95 if (Weights != null) weights = Weights.CloneAsArray(); 108 var solution = CreateNearestNeighbourRegressionSolution(Problem.ProblemData, K, SelfMatch,weights);96 var solution = CreateNearestNeighbourRegressionSolution(Problem.ProblemData, K, weights); 109 97 Results.Add(new Result(NearestNeighbourRegressionModelResultName, "The nearest neighbour regression solution.", solution)); 110 98 } 111 99 112 public static IRegressionSolution CreateNearestNeighbourRegressionSolution(IRegressionProblemData problemData, int k, bool selfMatch = false,double[] weights = null) {100 public static IRegressionSolution CreateNearestNeighbourRegressionSolution(IRegressionProblemData problemData, int k, double[] weights = null) { 113 101 var clonedProblemData = (IRegressionProblemData)problemData.Clone(); 114 return new NearestNeighbourRegressionSolution(Train(problemData, k, selfMatch,weights), clonedProblemData);102 return new NearestNeighbourRegressionSolution(Train(problemData, k, weights), clonedProblemData); 115 103 } 116 104 117 public static INearestNeighbourModel Train(IRegressionProblemData problemData, int k, bool selfMatch = false,double[] weights = null) {105 public static INearestNeighbourModel Train(IRegressionProblemData problemData, int k, double[] weights = null) { 118 106 return new NearestNeighbourModel(problemData.Dataset, 119 107 problemData.TrainingIndices, 120 108 k, 121 selfMatch,122 109 problemData.TargetVariable, 123 110 problemData.AllowedInputVariables,
Note: See TracChangeset
for help on using the changeset viewer.