Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3026:

  • refactored ranged based VMs -> created new 'base' class for ranged based VMs RangedValueBaseVM
  • renamed AddChilds to AddChildren
  • implemented ArrayValueVM and JsonItemArrayValueControl
  • added ranges for array and matrix values
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() { 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.AddChildren(new JsonItem() {
30        Name = "Dataset",
31        Value = dataInfo.GetValue(dataset)
32      });
33
34      IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables;
35      item.AddChildren(new JsonItem() {
36        Name = "TargetVariable",
37        Value = (object)targetVariable,
38        Range = variables.Select(x => x.Value)
39      });
40
41
42      item.AddChildren(new JsonItem() {
43        Name = "AllowedInputVariables",
44        Value = (object)val.AllowedInputVariables,
45        Range = variables.Select(x => x.Value)
46      });
47      return item;
48    }
49  }
50}
Note: See TracBrowser for help on using the repository browser.