Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Results.cs @ 1129

Last change on this file since 1129 was 1129, checked in by gkronber, 15 years ago

worked on RDF backend. Implemented query support to load datasets. Queries for dispatcher and results still missing. (#419)

File size: 4.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Collections;
28using HeuristicLab.CEDMA.DB.Interfaces;
29using System.Xml;
30using System.Runtime.Serialization;
31using System.IO;
32using HeuristicLab.PluginInfrastructure;
33using HeuristicLab.Data;
34using HeuristicLab.DataAnalysis;
35using System.Drawing;
36
37namespace HeuristicLab.CEDMA.Core {
38  public class Results : ItemBase {
39    public static string[] CategoricalVariables {
40      get { return new string[] { "TargetVariable" }; }
41    }
42
43    public static string[] OrdinalVariables {
44      get { return new string[] { "ValidationMeanAbsolutePercentageError" }; }
45    }
46
47    private IStore store;
48    public IStore Store {
49      get { return store; }
50      set {
51        store = value;
52      }
53    }
54
55    private Entity dataSetEntity;
56
57    public Results(IStore store) {
58      this.store = store;
59    }
60
61    internal void FilterDataSet(Entity entity) {
62      this.dataSetEntity = entity;
63    }
64
65    private List<ResultsEntry> entries = null;
66    private bool cached = false;
67    public IEnumerable<ResultsEntry> GetEntries() {
68      if (!cached)
69        return SelectRows();
70      return entries.AsEnumerable();
71    }
72
73    private IEnumerable<ResultsEntry> SelectRows() {
74      if (store == null) yield break;
75
76      //var models = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity));
77
78      ////var results = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity))
79      ////   .SelectMany(x => store.Select(new SelectFilter(
80      ////     new Entity[] { (Entity)x.Property },
81      ////     new Entity[] { Ontology.PredicateModelAttribute },
82      ////     new Resource[] { Ontology.AnyEntity })))
83      ////   .SelectMany(x =>
84      ////     store.Select(
85      ////        new SelectFilter(
86      ////        new Entity[] { (Entity)x.Property },
87      ////        new Entity[] { Ontology.PredicateModelAttributeName },
88      ////        new Entity[] { Ontology.AnyEntity })).Select(y =>
89      ////          new {
90      ////            Model = x.Subject,
91      ////            Attribute = (Entity)x.Property,
92      ////            AttributeName = (Literal)y.Property
93      ////          }))
94      ////   .SelectMany(x =>
95      ////     store.Select(
96      ////       new Statement(x.Attribute, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity))
97      ////       .Select(y =>
98      ////         new {
99      ////           Model = x.Model.Uri,
100      ////           AttributeName = x.AttributeName.Value,
101      ////           AttributeValue = ((Literal)y.Property).Value
102      ////         })).GroupBy(x => x.Model);
103
104      //entries = new List<ResultsEntry>();
105      //foreach (var model in models) {
106      //  var attributes = store.Select(new Statement((Entity)model.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity));
107
108      //  foreach (var attr in attributes) {
109      //    var namesAndValues = store
110      //      .Select(new SelectFilter(new Entity[] { (Entity)attr.Property },
111      //        new Entity[] { Ontology.PredicateModelAttributeName, Ontology.PredicateModelAttributeValue },
112      //        new Entity[] { Ontology.AnyEntity }));
113      //  }
114      //}
115
116      //foreach (var row in results) {
117      //  ResultsEntry entry = new ResultsEntry(row.First().Model);
118      //  foreach (var attr in row) {
119      //    entry.Set((string)attr.AttributeName, attr.AttributeValue);
120      //  }
121      //  entries.Add(entry);
122      //  yield return entry;
123      //}
124
125      //FireChanged();
126      //cached = true;
127    }
128
129    internal IEnumerable<string> SelectModelAttributes() {
130      if (store == null) yield break;
131
132      //var attributeNames =
133      //  store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateModelAttributeName, Ontology.AnyEntity))
134      //  .Select(s => (string)((Literal)s.Property).Value)       
135      //  .Distinct();
136      //foreach (var name in attributeNames) {
137      //  yield return name;
138      //}
139    }
140  }
141}
Note: See TracBrowser for help on using the repository browser.