#region License Information
/* HeuristicLab
* Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HeuristicLab.Core;
using System.Collections;
using HeuristicLab.CEDMA.DB.Interfaces;
using System.Xml;
using System.Runtime.Serialization;
using System.IO;
using HeuristicLab.PluginInfrastructure;
using HeuristicLab.Data;
using HeuristicLab.DataAnalysis;
using System.Drawing;
namespace HeuristicLab.CEDMA.Core {
public class Results : ItemBase {
public static string[] CategoricalVariables {
get { return new string[] { "TargetVariable" }; }
}
public static string[] OrdinalVariables {
get { return new string[] { "ValidationMeanAbsolutePercentageError" }; }
}
private IStore store;
public IStore Store {
get { return store; }
set {
store = value;
}
}
private Entity dataSetEntity;
public Results(IStore store) {
this.store = store;
}
internal void FilterDataSet(Entity entity) {
this.dataSetEntity = entity;
}
private List entries = null;
private bool cached = false;
public IEnumerable GetEntries() {
if (!cached)
return SelectRows();
return entries.AsEnumerable();
}
private IEnumerable SelectRows() {
if (store == null) yield break;
//var models = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity));
////var results = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity))
//// .SelectMany(x => store.Select(new SelectFilter(
//// new Entity[] { (Entity)x.Property },
//// new Entity[] { Ontology.PredicateModelAttribute },
//// new Resource[] { Ontology.AnyEntity })))
//// .SelectMany(x =>
//// store.Select(
//// new SelectFilter(
//// new Entity[] { (Entity)x.Property },
//// new Entity[] { Ontology.PredicateModelAttributeName },
//// new Entity[] { Ontology.AnyEntity })).Select(y =>
//// new {
//// Model = x.Subject,
//// Attribute = (Entity)x.Property,
//// AttributeName = (Literal)y.Property
//// }))
//// .SelectMany(x =>
//// store.Select(
//// new Statement(x.Attribute, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity))
//// .Select(y =>
//// new {
//// Model = x.Model.Uri,
//// AttributeName = x.AttributeName.Value,
//// AttributeValue = ((Literal)y.Property).Value
//// })).GroupBy(x => x.Model);
//entries = new List();
//foreach (var model in models) {
// var attributes = store.Select(new Statement((Entity)model.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity));
// foreach (var attr in attributes) {
// var namesAndValues = store
// .Select(new SelectFilter(new Entity[] { (Entity)attr.Property },
// new Entity[] { Ontology.PredicateModelAttributeName, Ontology.PredicateModelAttributeValue },
// new Entity[] { Ontology.AnyEntity }));
// }
//}
//foreach (var row in results) {
// ResultsEntry entry = new ResultsEntry(row.First().Model);
// foreach (var attr in row) {
// entry.Set((string)attr.AttributeName, attr.AttributeValue);
// }
// entries.Add(entry);
// yield return entry;
//}
//FireChanged();
//cached = true;
}
internal IEnumerable SelectModelAttributes() {
if (store == null) yield break;
//var attributeNames =
// store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateModelAttributeName, Ontology.AnyEntity))
// .Select(s => (string)((Literal)s.Property).Value)
// .Distinct();
//foreach (var name in attributeNames) {
// yield return name;
//}
}
}
}