Changeset 18077 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
- Timestamp:
- 11/04/21 17:04:01 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r18057 r18077 22 22 23 23 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 24 if (data.Children.All(x => !x.Active)) 25 return; 26 24 27 var parameter = item as ValueParameter<IRegressionProblemData>; 25 28 26 DoubleMatrixJsonItem dataset = null;27 StringJsonItem targetVariable = null;28 IntRangeJsonItem testPartition = null;29 IntRangeJsonItem trainingPartition = null;30 StringArrayJsonItem allowedInputVariables = null;29 DoubleMatrixJsonItem datasetItem = null; 30 StringJsonItem targetVariableItem = null; 31 IntRangeJsonItem testPartitionItem = null; 32 IntRangeJsonItem trainingPartitionItem = null; 33 StringArrayJsonItem allowedInputVariablesItem = null; 31 34 32 35 // get all child items 33 36 foreach (var child in data.Children) { 37 if (!child.Active) 38 continue; 39 34 40 if (child.Path.EndsWith(Dataset)) 35 dataset = child as DoubleMatrixJsonItem;41 datasetItem = child as DoubleMatrixJsonItem; 36 42 else if (child.Path.EndsWith(TargetVariable)) 37 targetVariable = child as StringJsonItem;43 targetVariableItem = child as StringJsonItem; 38 44 else if (child.Path.EndsWith(TestPartition)) 39 testPartition = child as IntRangeJsonItem;45 testPartitionItem = child as IntRangeJsonItem; 40 46 else if (child.Path.EndsWith(TrainingPartition)) 41 trainingPartition = child as IntRangeJsonItem;47 trainingPartitionItem = child as IntRangeJsonItem; 42 48 else if (child.Path.EndsWith(AllowedInputVariables)) 43 allowedInputVariables = child as StringArrayJsonItem;49 allowedInputVariablesItem = child as StringArrayJsonItem; 44 50 } 45 51 46 52 // check data 47 if(!dataset .ColumnNames.Any(x => x == targetVariable.Value)) {48 throw new Exception($"The value of the target variable ('{targetVariable .Value}') has no matching row name value of the dataset.");53 if(!datasetItem.ColumnNames.Any(x => x == targetVariableItem.Value)) { 54 throw new Exception($"The value of the target variable ('{targetVariableItem.Value}') has no matching row name value of the dataset."); 49 55 } 50 56 51 foreach(var v in allowedInputVariables .Value) {52 if(!dataset .ColumnNames.Any(x => x == v))57 foreach(var v in allowedInputVariablesItem.Value) { 58 if(!datasetItem.ColumnNames.Any(x => x == v)) 53 59 throw new Exception($"The value of the input variable ('{v}') has no matching row name value of the dataset."); 54 60 } 55 61 56 62 // create the new problemData object 63 var dataset = datasetItem == null ? 64 parameter.Value.Dataset : 65 new Dataset(datasetItem.ColumnNames, datasetItem.Value); 66 67 var allowedInputVariables = allowedInputVariablesItem == null ? 68 parameter.Value.AllowedInputVariables : 69 allowedInputVariablesItem.Value; 70 71 var targetVariable = targetVariableItem == null ? 72 parameter.Value.TargetVariable : 73 targetVariableItem.Value; 74 57 75 var problemData = new RegressionProblemData( 58 new Dataset(dataset.ColumnNames, dataset.Value),59 allowedInputVariables .Value,60 targetVariable .Value);76 dataset, 77 allowedInputVariables, 78 targetVariable); 61 79 62 80 // set the new problemData
Note: See TracChangeset
for help on using the changeset viewer.