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 int Priority => 20;
|
---|
14 | public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("EE612297-B1AF-42D2-BF21-AF9A2D42791C"));
|
---|
15 |
|
---|
16 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
17 | // TODO: inject data
|
---|
18 | throw new NotImplementedException();
|
---|
19 | }
|
---|
20 |
|
---|
21 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
22 | IJsonItem item = new JsonItem() { Name = value.ItemName };
|
---|
23 |
|
---|
24 | dynamic val = (dynamic)value;
|
---|
25 | object dataset = (object)val.Dataset;
|
---|
26 | dynamic targetVariable = val.TargetVariable;
|
---|
27 | FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags);
|
---|
28 | // TODO: aufteilen in trainings und test daten abschnitte
|
---|
29 | item.AddChilds(new JsonItem() {
|
---|
30 | Name = "Dataset",
|
---|
31 | Value = dataInfo.GetValue(dataset)
|
---|
32 | });
|
---|
33 |
|
---|
34 | IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
|
---|
35 | item.AddChilds(new JsonItem() {
|
---|
36 | Name = "TargetVariable",
|
---|
37 | Value = (object)targetVariable,
|
---|
38 | Range = variables.Select(x => x.Value)
|
---|
39 | });
|
---|
40 |
|
---|
41 |
|
---|
42 | item.AddChilds(new JsonItem() {
|
---|
43 | Name = "AllowedInputVariables",
|
---|
44 | Value = (object)val.AllowedInputVariables,
|
---|
45 | Range = variables.Select(x => x.Value)
|
---|
46 | });
|
---|
47 | return item;
|
---|
48 | }
|
---|
49 | }
|
---|
50 | }
|
---|