Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17433 was 17433, checked in by dpiringe, 4 years ago

#3026:

  • added property Description in IJsonItem and updated all construction calls
  • updated UnsupportedJsonItem with unsupported property Description
  • updated JsonItemBaseControl and JsonItemVMBase for new property Description
File size: 1.8 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 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() {
23        Name = value.ItemName,
24        Description = value.ItemDescription
25      };
26
27      dynamic val = (dynamic)value;
28      object dataset = (object)val.Dataset;
29      dynamic targetVariable = val.TargetVariable;
30      FieldInfo dataInfo = dataset.GetType().GetField("storableData", flags);
31      // TODO: aufteilen in trainings und test daten abschnitte
32      item.AddChildren(new JsonItem() {
33        Name = "Dataset",
34        Value = dataInfo.GetValue(dataset)
35      });
36
37      IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
38      item.AddChildren(new JsonItem() {
39        Name = "TargetVariable",
40        Value = (object)targetVariable,
41        Range = variables.Select(x => x.Value)
42      });
43
44
45      item.AddChildren(new JsonItem() {
46        Name = "AllowedInputVariables",
47        Value = (object)val.AllowedInputVariables,
48        Range = variables.Select(x => x.Value)
49      });
50      return item;
51    }
52  }
53}
Note: See TracBrowser for help on using the repository browser.