1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Reflection;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using HeuristicLab.Core;
|
---|
8 | using HeuristicLab.Data;
|
---|
9 |
|
---|
10 | namespace 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 | Children = new List<JsonItem>()
|
---|
17 | };
|
---|
18 |
|
---|
19 | dynamic val = (dynamic)value;
|
---|
20 | object dataset = (object)val.Dataset;
|
---|
21 | dynamic targetVariable = val.TargetVariable;
|
---|
22 | FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags);
|
---|
23 | // TODO: aufteilen in trainings und test daten abschnitte
|
---|
24 | item.Children.Add(new JsonItem() {
|
---|
25 | Name = "Dataset",
|
---|
26 | Value = dataInfo.GetValue(dataset),
|
---|
27 | Path = "Dataset"
|
---|
28 | });
|
---|
29 |
|
---|
30 | IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
|
---|
31 | item.Children.Add(new JsonItem() {
|
---|
32 | Name = "TargetVariable",
|
---|
33 | Value = (object)targetVariable,
|
---|
34 | Range = variables.Select(x => x.Value),
|
---|
35 | Path = "TargetVariable"
|
---|
36 | });
|
---|
37 |
|
---|
38 |
|
---|
39 | item.Children.Add(new JsonItem() {
|
---|
40 | Name = "AllowedInputVariables",
|
---|
41 | Value = (object)val.AllowedInputVariables,
|
---|
42 | Range = variables.Select(x => x.Value),
|
---|
43 | Path = "AllowedInputVariables"
|
---|
44 | });
|
---|
45 |
|
---|
46 | item.UpdatePath();
|
---|
47 |
|
---|
48 | return item;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public override void InjectData(IItem item, JsonItem data) {
|
---|
52 | // TODO: inject data
|
---|
53 | throw new NotImplementedException();
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|