source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs @ 17375

Last change on this file since 17375 was 17375, checked in by dpiringe, 23 months ago

#3026:

  • added new converter RegressionProblemDataConverter
  • added new unit test class (only a skeleton)
File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Core;
8using HeuristicLab.Data;
9
10namespace HeuristicLab.JsonInterface {
11  public class RegressionProblemDataConverter : BaseConverter {
12    private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
13    public override JsonItem ExtractData(IItem value) {
14      JsonItem item = new JsonItem() {
15        Path = value.ItemName,
16        Parameters = new List<JsonItem>()
17      };
18
19      Type type = value.GetType();
20
21      dynamic val = (dynamic)value;
22      object dataset = (object)val.Dataset;
23      dynamic targetVariable = val.TargetVariable;
24      FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags);
25      // TODO: aufteilen in trainings und test daten abschnitte
26      item.Parameters.Add(new JsonItem() {
27        Name = "Dataset",
28        Value = dataInfo.GetValue(dataset),
29        Path = "Dataset"
30      });
31
32      IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
33      item.Parameters.Add(new JsonItem() {
34        Name = "TargetVariable",
35        Value = (object)targetVariable,
36        Range = variables.Select(x => x.Value),
37        Path = "TargetVariable"
38      });
39
40
41      item.Parameters.Add(new JsonItem() {
42        Name = "AllowedInputVariables",
43        Value = (object)val.AllowedInputVariables,
44        Range = variables.Select(x => x.Value),
45        Path = "AllowedInputVariables"
46      });
47
48      /*
49      item.Parameters.Add(new JsonItem() {
50        Name = "InputVariables",
51        Value = variables.Select(x => x.Value),
52        Path = "InputVariables"
53      });
54      */
55      item.UpdatePath();
56
57      return item;
58    }
59
60    public override void InjectData(IItem item, JsonItem data) {
61      throw new NotImplementedException();
62    }
63  }
64}
Note: See TracBrowser for help on using the repository browser.