- Timestamp:
- 06/28/16 13:33:17 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassification.cs
r13238 r13941 220 220 221 221 var problemDataClone = (IClassificationProblemData)problemData.Clone(); 222 return new NeuralNetworkClassificationSolution( problemDataClone, new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()));222 return new NeuralNetworkClassificationSolution(new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()), problemDataClone); 223 223 } 224 224 #endregion -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkClassificationSolution.cs
r12012 r13941 43 43 : base(original, cloner) { 44 44 } 45 public NeuralNetworkClassificationSolution(I ClassificationProblemData problemData, INeuralNetworkModel nnModel)45 public NeuralNetworkClassificationSolution(INeuralNetworkModel nnModel, IClassificationProblemData problemData) 46 46 : base(nnModel, problemData) { 47 47 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassification.cs
r13238 r13941 204 204 relClassError = alglib.mlperelclserror(mlpEnsemble, inputMatrix, nRows); 205 205 var problemDataClone = (IClassificationProblemData)problemData.Clone(); 206 return new NeuralNetworkEnsembleClassificationSolution( problemDataClone, new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()));206 return new NeuralNetworkEnsembleClassificationSolution(new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables, problemDataClone.ClassValues.ToArray()), problemDataClone); 207 207 } 208 208 #endregion -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassificationSolution.cs
r12012 r13941 43 43 : base(original, cloner) { 44 44 } 45 public NeuralNetworkEnsembleClassificationSolution(I ClassificationProblemData problemData, INeuralNetworkEnsembleModel nnModel)45 public NeuralNetworkEnsembleClassificationSolution(INeuralNetworkEnsembleModel nnModel, IClassificationProblemData problemData) 46 46 : base(nnModel, problemData) { 47 47 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleModel.cs
r13921 r13941 34 34 [StorableClass] 35 35 [Item("NeuralNetworkEnsembleModel", "Represents a neural network ensemble for regression and classification.")] 36 public sealed class NeuralNetworkEnsembleModel : NamedItem, INeuralNetworkEnsembleModel {36 public sealed class NeuralNetworkEnsembleModel : ClassificationModel, INeuralNetworkEnsembleModel { 37 37 38 38 private alglib.mlpensemble mlpEnsemble; … … 48 48 } 49 49 50 public string TargetVariable { 51 get { return targetVariable; } 52 } 53 54 public IEnumerable<string> VariablesUsedForPrediction { 50 public override IEnumerable<string> VariablesUsedForPrediction { 55 51 get { return allowedInputVariables; } 56 52 } … … 80 76 } 81 77 public NeuralNetworkEnsembleModel(alglib.mlpensemble mlpEnsemble, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null) 82 : base( ) {78 : base(targetVariable) { 83 79 this.name = ItemName; 84 80 this.description = ItemDescription; … … 111 107 } 112 108 113 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {109 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 114 110 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 115 111 … … 137 133 } 138 134 139 public INeuralNetworkEnsembleRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 140 return new NeuralNetworkEnsembleRegressionSolution(new RegressionEnsembleProblemData(problemData), this); 141 } 142 IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) { 143 return CreateRegressionSolution(problemData); 144 } 145 public INeuralNetworkEnsembleClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 146 return new NeuralNetworkEnsembleClassificationSolution(new ClassificationEnsembleProblemData(problemData), this); 147 } 148 IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) { 149 return CreateClassificationSolution(problemData); 135 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 136 return new NeuralNetworkEnsembleRegressionSolution(this, new RegressionEnsembleProblemData(problemData)); 137 } 138 public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 139 return new NeuralNetworkEnsembleClassificationSolution(this, new ClassificationEnsembleProblemData(problemData)); 150 140 } 151 141 -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegression.cs
r13238 r13941 190 190 avgRelError = alglib.mlpeavgrelerror(mlpEnsemble, inputMatrix, nRows); 191 191 192 return new NeuralNetworkEnsembleRegressionSolution( (IRegressionProblemData)problemData.Clone(), new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables));192 return new NeuralNetworkEnsembleRegressionSolution(new NeuralNetworkEnsembleModel(mlpEnsemble, targetVariable, allowedInputVariables), (IRegressionProblemData)problemData.Clone()); 193 193 } 194 194 #endregion -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegressionSolution.cs
r12012 r13941 43 43 : base(original, cloner) { 44 44 } 45 public NeuralNetworkEnsembleRegressionSolution(I RegressionProblemData problemData, INeuralNetworkEnsembleModel nnModel)45 public NeuralNetworkEnsembleRegressionSolution(INeuralNetworkEnsembleModel nnModel, IRegressionProblemData problemData) 46 46 : base(nnModel, problemData) { 47 47 RecalculateResults(); -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs
r13921 r13941 34 34 [StorableClass] 35 35 [Item("NeuralNetworkModel", "Represents a neural network for regression and classification.")] 36 public sealed class NeuralNetworkModel : NamedItem, INeuralNetworkModel {36 public sealed class NeuralNetworkModel : ClassificationModel, INeuralNetworkModel { 37 37 38 38 private alglib.multilayerperceptron multiLayerPerceptron; … … 48 48 } 49 49 50 public IEnumerable<string> VariablesUsedForPrediction {50 public override IEnumerable<string> VariablesUsedForPrediction { 51 51 get { return allowedInputVariables; } 52 52 } 53 53 54 public string TargetVariable {55 get { return targetVariable; }56 }57 58 [Storable]59 private string targetVariable;60 54 [Storable] 61 55 private string[] allowedInputVariables; … … 82 76 multiLayerPerceptron.innerobj.x = (double[])original.multiLayerPerceptron.innerobj.x.Clone(); 83 77 multiLayerPerceptron.innerobj.y = (double[])original.multiLayerPerceptron.innerobj.y.Clone(); 84 targetVariable = original.targetVariable;85 78 allowedInputVariables = (string[])original.allowedInputVariables.Clone(); 86 79 if (original.classValues != null) … … 88 81 } 89 82 public NeuralNetworkModel(alglib.multilayerperceptron multiLayerPerceptron, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null) 90 : base( ) {83 : base(targetVariable) { 91 84 this.name = ItemName; 92 85 this.description = ItemDescription; 93 86 this.multiLayerPerceptron = multiLayerPerceptron; 94 this.targetVariable = targetVariable;95 87 this.allowedInputVariables = allowedInputVariables.ToArray(); 96 88 if (classValues != null) … … 119 111 } 120 112 121 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {113 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 122 114 double[,] inputData = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 123 115 … … 145 137 } 146 138 147 public INeuralNetworkRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 148 return new NeuralNetworkRegressionSolution(new RegressionProblemData(problemData), this); 149 } 150 IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) { 151 return CreateRegressionSolution(problemData); 152 } 153 public INeuralNetworkClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 154 return new NeuralNetworkClassificationSolution(new ClassificationProblemData(problemData), this); 155 } 156 IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) { 157 return CreateClassificationSolution(problemData); 139 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 140 return new NeuralNetworkRegressionSolution(this, new RegressionProblemData(problemData)); 141 } 142 public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 143 return new NeuralNetworkClassificationSolution(this, new ClassificationProblemData(problemData)); 158 144 } 159 145 -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegression.cs
r13238 r13941 207 207 avgRelError = alglib.mlpavgrelerror(multiLayerPerceptron, inputMatrix, nRows); 208 208 209 return new NeuralNetworkRegressionSolution( (IRegressionProblemData)problemData.Clone(), new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables));209 return new NeuralNetworkRegressionSolution(new NeuralNetworkModel(multiLayerPerceptron, targetVariable, allowedInputVariables), (IRegressionProblemData)problemData.Clone()); 210 210 } 211 211 #endregion -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegressionSolution.cs
r12012 r13941 43 43 : base(original, cloner) { 44 44 } 45 public NeuralNetworkRegressionSolution(I RegressionProblemData problemData, INeuralNetworkModel nnModel)45 public NeuralNetworkRegressionSolution(INeuralNetworkModel nnModel, IRegressionProblemData problemData) 46 46 : base(nnModel, problemData) { 47 47 }
Note: See TracChangeset
for help on using the changeset viewer.