Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3026:

  • removed classes:
    • CheckedItemListConverter: unnecessary
    • ItemCollectionConverter: unnecessary
    • PrimitiveConverter: not possible to implement because it needs to Extract/Inject from/into objects (but interfaces pretends IItem)
    • StorableConverter: unnecessary
    • ConfigurableConverter: unnecessary
  • removed graphviz code in Heuristiclab.ConfigStarter/Program.cs
  • updated Constants
  • some simple code refactors in BaseConverter
  • in JsonItem:
    • renamed Parameters -> Children
    • removed Properties: Operators, Type, Reference, IsConfigurable, IsParameterizedItem
    • removed unnecessary/old code
  • implemented a new way to get data from an object, which is a matrix, in ValueTypeMatrixConverter method: CopyMatrixData
    • converts the object into an array -> rows: from array.Length, cols: when the length is > 0 pick length of first array of index 0 (it is saved as an array of arrays)
  • created a binding flag const in ValueRangeConverter to prevent duplicates in code
File size: 1.7 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 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}
Note: See TracBrowser for help on using the repository browser.