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 | 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 | }
|
---|