Changeset 13083


Ignore:
Timestamp:
10/29/15 18:33:51 (4 years ago)
Author:
gkronber
Message:

#1998: merged changesets r10551:13081 (only on HeuristicLab.Problems.DataAnalysis) from trunk to branch

Location:
branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis
Files:
94 edited
8 copied

Legend:

Unmodified
Added
Removed
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis

  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3333  [Item("Dataset", "Represents a dataset containing data that should be analyzed.")]
    3434  [StorableClass]
    35   public sealed class Dataset : NamedItem, IStringConvertibleMatrix {
     35  public class Dataset : NamedItem, IDataset {
    3636    [StorableConstructor]
    37     private Dataset(bool deserializing) : base(deserializing) { }
    38     private Dataset(Dataset original, Cloner cloner)
     37    protected Dataset(bool deserializing) : base(deserializing) { }
     38    protected Dataset(Dataset original, Cloner cloner)
    3939      : base(original, cloner) {
    4040      variableValues = new Dictionary<string, IList>(original.variableValues);
     
    118118    }
    119119
     120    protected Dataset(Dataset dataset) : this(dataset.variableNames, dataset.variableValues.Values) { }
     121
    120122    #region Backwards compatible code, remove with 3.5
    121123    private double[,] storableData;
     
    143145
    144146    [Storable(Name = "VariableValues")]
    145     private Dictionary<string, IList> variableValues;
    146 
    147     private List<string> variableNames;
     147    protected Dictionary<string, IList> variableValues;
     148
     149    protected List<string> variableNames;
    148150    [Storable]
    149151    public IEnumerable<string> VariableNames {
    150152      get { return variableNames; }
    151       private set {
     153      protected set {
    152154        if (variableNames != null) throw new InvalidOperationException();
    153155        variableNames = new List<string>(value);
    154156      }
    155157    }
    156 
    157158    public IEnumerable<string> DoubleVariables {
    158159      get { return variableValues.Where(p => p.Value is List<double>).Select(p => p.Key); }
    159160    }
    160 
    161161    public IEnumerable<double> GetDoubleValues(string variableName) {
     162      return GetValues<double>(variableName);
     163    }
     164    public IEnumerable<string> GetStringValues(string variableName) {
     165      return GetValues<string>(variableName);
     166    }
     167    public IEnumerable<DateTime> GetDateTimeValues(string variableName) {
     168      return GetValues<DateTime>(variableName);
     169    }
     170
     171    public ReadOnlyCollection<double> GetReadOnlyDoubleValues(string variableName) {
     172      var values = GetValues<double>(variableName);
     173      return values.AsReadOnly();
     174    }
     175    public double GetDoubleValue(string variableName, int row) {
     176      var values = GetValues<double>(variableName);
     177      return values[row];
     178    }
     179    public IEnumerable<double> GetDoubleValues(string variableName, IEnumerable<int> rows) {
     180      return GetValues<double>(variableName, rows);
     181    }
     182    private IEnumerable<T> GetValues<T>(string variableName, IEnumerable<int> rows) {
     183      var values = GetValues<T>(variableName);
     184      return rows.Select(x => values[x]);
     185    }
     186    private List<T> GetValues<T>(string variableName) {
    162187      IList list;
    163188      if (!variableValues.TryGetValue(variableName, out list))
    164189        throw new ArgumentException("The variable " + variableName + " does not exist in the dataset.");
    165       List<double> values = list as List<double>;
    166       if (values == null) throw new ArgumentException("The variable " + variableName + " is not a double variable.");
    167 
    168       //mkommend yield return used to enable lazy evaluation
    169       foreach (double value in values)
    170         yield return value;
    171     }
    172     public ReadOnlyCollection<double> GetReadOnlyDoubleValues(string variableName) {
    173       IList list;
    174       if (!variableValues.TryGetValue(variableName, out list))
    175         throw new ArgumentException("The variable " + variableName + " does not exist in the dataset.");
    176       List<double> values = list as List<double>;
    177       if (values == null) throw new ArgumentException("The variable " + variableName + " is not a double variable.");
    178       return values.AsReadOnly();
    179     }
    180     public double GetDoubleValue(string variableName, int row) {
    181       IList list;
    182       if (!variableValues.TryGetValue(variableName, out list))
    183         throw new ArgumentException("The variable " + variableName + " does not exist in the dataset.");
    184       List<double> values = list as List<double>;
    185       if (values == null) throw new ArgumentException("The variable " + variableName + " is not a double variable.");
    186       return values[row];
    187     }
    188     public IEnumerable<double> GetDoubleValues(string variableName, IEnumerable<int> rows) {
    189       IList list;
    190       if (!variableValues.TryGetValue(variableName, out list))
    191         throw new ArgumentException("The variable " + variableName + " does not exist in the dataset.");
    192       List<double> values = list as List<double>;
    193       if (values == null) throw new ArgumentException("The variable " + variableName + " is not a double variable.");
    194 
    195       return rows.Select(index => values[index]);
     190      List<T> values = list as List<T>;
     191      if (values == null) throw new ArgumentException("The variable " + variableName + " is not a " + typeof(T) + " variable.");
     192      return values;
     193    }
     194    public bool VariableHasType<T>(string variableName) {
     195      return variableValues[variableName] is IList<T>;
    196196    }
    197197
    198198    #region IStringConvertibleMatrix Members
    199199    [Storable]
    200     private int rows;
     200    protected int rows;
    201201    public int Rows {
    202202      get { return rows; }
     
    207207      set { throw new NotSupportedException(); }
    208208    }
    209 
    210209    public bool SortableView {
    211210      get { return false; }
     
    215214      get { return true; }
    216215    }
    217 
    218216    IEnumerable<string> IStringConvertibleMatrix.ColumnNames {
    219217      get { return this.VariableNames; }
     
    224222      set { throw new NotSupportedException(); }
    225223    }
    226 
    227224    public string GetValue(int rowIndex, int columnIndex) {
    228225      return variableValues[variableNames[columnIndex]][rowIndex].ToString();
    229226    }
    230     public bool SetValue(string value, int rowIndex, int columnIndex) {
     227    bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
    231228      throw new NotSupportedException();
    232229    }
    233     public bool Validate(string value, out string errorMessage) {
     230    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    234231      throw new NotSupportedException();
    235232    }
    236233
    237     public event EventHandler ColumnsChanged { add { } remove { } }
    238     public event EventHandler RowsChanged { add { } remove { } }
    239     public event EventHandler ColumnNamesChanged { add { } remove { } }
    240     public event EventHandler RowNamesChanged { add { } remove { } }
    241     public event EventHandler SortableViewChanged { add { } remove { } }
    242     public event EventHandler<EventArgs<int, int>> ItemChanged { add { } remove { } }
    243     public event EventHandler Reset { add { } remove { } }
     234    public virtual event EventHandler ColumnsChanged { add { } remove { } }
     235    public virtual event EventHandler RowsChanged { add { } remove { } }
     236    public virtual event EventHandler ColumnNamesChanged { add { } remove { } }
     237    public virtual event EventHandler RowNamesChanged { add { } remove { } }
     238    public virtual event EventHandler SortableViewChanged { add { } remove { } }
     239    public virtual event EventHandler<EventArgs<int, int>> ItemChanged { add { } remove { } }
     240    public virtual event EventHandler Reset { add { } remove { } }
    244241    #endregion
    245242  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/DatasetExtensions.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/DoubleLimit.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r13081 r13083  
    164164    </Compile>
    165165    <Compile Include="Implementation\Classification\ClassificationEnsembleSolution.cs" />
     166    <Compile Include="Implementation\Classification\ClassificationPerformanceMeasures.cs" />
    166167    <Compile Include="Implementation\Classification\ClassificationProblemData.cs" />
    167168    <Compile Include="Implementation\Classification\ClassificationProblem.cs" />
     
    189190    <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolution.cs" />
    190191    <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolutionBase.cs" />
     192    <Compile Include="Implementation\Transformations\CopyColumnTransformation.cs" />
     193    <Compile Include="Implementation\Transformations\ExponentialTransformation.cs" />
     194    <Compile Include="Implementation\Transformations\LinearTransformation.cs" />
     195    <Compile Include="Implementation\Transformations\LogarithmicTransformation.cs" />
     196    <Compile Include="Implementation\Transformations\PowerTransformation.cs" />
     197    <Compile Include="Implementation\Transformations\ReciprocalTransformation.cs" />
     198    <Compile Include="Implementation\Transformations\ShiftStandardDistributionTransformation.cs" />
     199    <Compile Include="Implementation\Transformations\ShiftToRangeTransformation.cs" />
     200    <Compile Include="Implementation\Transformations\Transformation.cs" />
    191201    <Compile Include="Interfaces\Classification\IClassificationEnsembleModel.cs">
    192202      <SubType>Code</SubType>
     
    197207    <Compile Include="Interfaces\Classification\IDiscriminantFunctionThresholdCalculator.cs" />
    198208    <Compile Include="Interfaces\IDataAnalysisSolutionExporter.cs" />
     209    <Compile Include="Interfaces\IDataset.cs" />
    199210    <Compile Include="Interfaces\IDependencyCalculator.cs" />
     211    <Compile Include="Interfaces\ITransformation.cs" />
     212    <Compile Include="Interfaces\ITransformationMapper.cs" />
    200213    <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs">
    201214      <SubType>Code</SubType>
     
    208221    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisProblemData.cs" />
    209222    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisSolution.cs" />
     223    <Compile Include="ModifiableDataset.cs" />
    210224    <Compile Include="OnlineCalculators\AutoCorrelationCalculator.cs" />
     225    <Compile Include="OnlineCalculators\ClassificationPerformanceMeasuresCalculator.cs" />
    211226    <Compile Include="OnlineCalculators\ConfusionMatrixCalculator.cs" />
    212227    <Compile Include="OnlineCalculators\DependencyCalculator\HoeffdingsDependenceCalculator.cs" />
     
    254269    <Compile Include="OnlineCalculators\OnlineMeanSquaredErrorCalculator.cs" />
    255270    <Compile Include="OnlineCalculators\OnlineNormalizedMeanSquaredErrorCalculator.cs" />
     271    <Compile Include="OnlineCalculators\OnlinePearsonsRCalculator.cs" />
    256272    <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" />
    257273    <Compile Include="Implementation\Regression\RegressionSolution.cs" />
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    6767    }
    6868
    69     public IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(Dataset dataset, IEnumerable<int> rows) {
     69    public IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(IDataset dataset, IEnumerable<int> rows) {
    7070      var estimatedValuesEnumerators = (from model in models
    7171                                        select model.GetEstimatedClassValues(dataset, rows).GetEnumerator())
     
    8282    #region IClassificationModel Members
    8383
    84     public IEnumerable<double> GetEstimatedClassValues(Dataset dataset, IEnumerable<int> rows) {
     84    public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    8585      foreach (var estimatedValuesVector in GetEstimatedClassValueVectors(dataset, rows)) {
    8686        // return the class which is most often occuring
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    7979      this.TestPartition.Start = classificationProblemData.TestPartition.Start;
    8080      this.TestPartition.End = classificationProblemData.TestPartition.End;
     81      this.PositiveClass = classificationProblemData.PositiveClass;
    8182    }
    8283
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3535  [StorableClass]
    3636  [Item("Classification Ensemble Solution", "A classification solution that contains an ensemble of multiple classification models")]
    37   [Creatable("Data Analysis - Ensembles")]
     37  [Creatable(CreatableAttribute.Categories.DataAnalysisEnsembles, Priority = 110)]
    3838  public sealed class ClassificationEnsembleSolution : ClassificationSolutionBase, IClassificationEnsembleSolution {
    3939    private readonly Dictionary<int, double> trainingEvaluationCache = new Dictionary<int, double>();
     
    4949    }
    5050
     51    [Storable]
    5152    private readonly ItemCollection<IClassificationSolution> classificationSolutions;
    5253    public IItemCollection<IClassificationSolution> ClassificationSolutions {
     
    6667    [StorableHook(HookType.AfterDeserialization)]
    6768    private void AfterDeserialization() {
    68       foreach (var model in Model.Models) {
    69         IClassificationProblemData problemData = (IClassificationProblemData)ProblemData.Clone();
    70         problemData.TrainingPartition.Start = trainingPartitions[model].Start;
    71         problemData.TrainingPartition.End = trainingPartitions[model].End;
    72         problemData.TestPartition.Start = testPartitions[model].Start;
    73         problemData.TestPartition.End = testPartitions[model].End;
    74 
    75         classificationSolutions.Add(model.CreateClassificationSolution(problemData));
     69      if (!classificationSolutions.Any()) {
     70        foreach (var model in Model.Models) {
     71          IClassificationProblemData problemData = (IClassificationProblemData)ProblemData.Clone();
     72          problemData.TrainingPartition.Start = trainingPartitions[model].Start;
     73          problemData.TrainingPartition.End = trainingPartitions[model].End;
     74          problemData.TestPartition.Start = testPartitions[model].Start;
     75          problemData.TestPartition.End = testPartitions[model].End;
     76
     77          classificationSolutions.Add(model.CreateClassificationSolution(problemData));
     78        }
    7679      }
    7780      RegisterClassificationSolutionsEventHandler();
     
    231234    }
    232235
    233     public IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(Dataset dataset, IEnumerable<int> rows) {
     236    public IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(IDataset dataset, IEnumerable<int> rows) {
    234237      if (!Model.Models.Any()) yield break;
    235238      var estimatedValuesEnumerators = (from model in Model.Models
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727  [StorableClass]
    2828  [Item("Classification Problem", "A general classification problem.")]
    29   [Creatable("Problems")]
    3029  public class ClassificationProblem : DataAnalysisProblem<IClassificationProblemData>, IClassificationProblem, IStorableContent {
    3130    public string Filename { get; set; }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3636    protected const string ClassNamesParameterName = "ClassNames";
    3737    protected const string ClassificationPenaltiesParameterName = "ClassificationPenalties";
     38    protected const string PositiveClassParameterName = "PositiveClass";
    3839    protected const int MaximumNumberOfClasses = 100;
    3940    protected const int InspectedRowsToDetermineTargets = 2000;
     
    213214      get { return (IFixedValueParameter<StringMatrix>)Parameters[ClassNamesParameterName]; }
    214215    }
     216    public IConstrainedValueParameter<StringValue> PositiveClassParameter {
     217      get { return (IConstrainedValueParameter<StringValue>)Parameters[PositiveClassParameterName]; }
     218    }
    215219    public IFixedValueParameter<DoubleMatrix> ClassificationPenaltiesParameter {
    216220      get { return (IFixedValueParameter<DoubleMatrix>)Parameters[ClassificationPenaltiesParameterName]; }
     
    262266      get { return ClassNamesCache; }
    263267    }
     268
     269    public string PositiveClass {
     270      get { return PositiveClassParameter.Value.Value; }
     271      set {
     272        var matchingValue = PositiveClassParameter.ValidValues.SingleOrDefault(x => x.Value == value);
     273        if (matchingValue == null) throw new ArgumentException(string.Format("{0} cannot be set as positive class.", value));
     274        PositiveClassParameter.Value = matchingValue;
     275      }
     276    }
    264277    #endregion
    265278
     
    270283    private void AfterDeserialization() {
    271284      RegisterParameterEvents();
     285      // BackwardsCompatibility3.4
     286      #region Backwards compatible code, remove with 3.5
     287      if (!Parameters.ContainsKey(PositiveClassParameterName)) {
     288        var validValues = new ItemSet<StringValue>(ClassNames.Select(s => new StringValue(s).AsReadOnly()));
     289        Parameters.Add(new ConstrainedValueParameter<StringValue>(PositiveClassParameterName,
     290          "The positive class which is used for quality measure calculation (e.g., specifity, sensitivity,...)", validValues, validValues.First()));
     291      }
     292      #endregion
     293
    272294    }
    273295
     
    290312      TestPartition.End = classificationProblemData.TestPartition.End;
    291313
     314      PositiveClass = classificationProblemData.PositiveClass;
     315
    292316      for (int i = 0; i < classificationProblemData.ClassNames.Count(); i++)
    293317        ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);
     
    300324    }
    301325
    302     public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    303       : base(dataset, allowedInputVariables) {
     326    public ClassificationProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null)
     327      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    304328      var validTargetVariableValues = CheckVariablesForPossibleTargetVariables(dataset).Select(x => new StringValue(x).AsReadOnly()).ToList();
    305329      var target = validTargetVariableValues.Where(x => x.Value == targetVariable).DefaultIfEmpty(validTargetVariableValues.First()).First();
     
    307331      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(validTargetVariableValues), target));
    308332      Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, ""));
     333      Parameters.Add(new ConstrainedValueParameter<StringValue>(PositiveClassParameterName, "The positive class which is used for quality measure calculation (e.g., specifity, sensitivity,...)"));
    309334      Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, ""));
    310335
     
    313338    }
    314339
    315     public static IEnumerable<string> CheckVariablesForPossibleTargetVariables(Dataset dataset) {
     340    public static IEnumerable<string> CheckVariablesForPossibleTargetVariables(IDataset dataset) {
    316341      int maxSamples = Math.Min(InspectedRowsToDetermineTargets, dataset.Rows);
    317342      var validTargetVariables = (from v in dataset.DoubleVariables
     
    339364      ClassNamesParameter.Value.ColumnNames = new List<string>() { "ClassNames" };
    340365      ClassNamesParameter.Value.RowNames = ClassValues.Select(s => "ClassValue: " + s);
     366
     367      PositiveClassParameter.ValidValues.Clear();
     368      foreach (var className in ClassNames) {
     369        PositiveClassParameter.ValidValues.Add(new StringValue(className).AsReadOnly());
     370      }
    341371
    342372      ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Rows = Classes;
     
    411441    }
    412442    private void Parameter_ValueChanged(object sender, EventArgs e) {
     443      var oldPositiveClass = PositiveClass;
     444      var oldClassNames = classNamesCache;
     445      var index = oldClassNames.IndexOf(oldPositiveClass);
     446
    413447      classNamesCache = null;
    414448      ClassificationPenaltiesParameter.Value.RowNames = ClassNames.Select(name => "Actual " + name);
    415449      ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name);
     450
     451      PositiveClassParameter.ValidValues.Clear();
     452      foreach (var className in ClassNames) {
     453        PositiveClassParameter.ValidValues.Add(new StringValue(className).AsReadOnly());
     454      }
     455      PositiveClassParameter.Value = PositiveClassParameter.ValidValues.ElementAt(index);
     456
    416457      OnChanged();
    417458    }
     
    435476      if (!newClassValues.SequenceEqual(ClassValues)) {
    436477        errorMessage = errorMessage + string.Format("The class values differ in the provided classification problem data.");
    437         return false;
     478        returnValue = false;
     479      }
     480
     481      var newPositivieClassName = classificationProblemData.PositiveClass;
     482      if (newPositivieClassName != PositiveClass) {
     483        errorMessage = errorMessage + string.Format("The positive class differs in the provided classification problem data.");
     484        returnValue = false;
    438485      }
    439486
     
    452499        ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);
    453500
     501      PositiveClass = classificationProblemData.PositiveClass;
     502
    454503      for (int i = 0; i < Classes; i++) {
    455504        for (int j = 0; j < Classes; j++) {
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3030  /// </summary>
    3131  [StorableClass]
    32   public abstract class ClassificationSolution : ClassificationSolutionBase {
     32  public class ClassificationSolution : ClassificationSolutionBase {
    3333    protected readonly Dictionary<int, double> evaluationCache;
    3434
     
    4646      evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows);
    4747      CalculateClassificationResults();
     48    }
     49
     50    public override IDeepCloneable Clone(Cloner cloner) {
     51      return new ClassificationSolution(this, cloner);
    4852    }
    4953
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3434    private const string TrainingNormalizedGiniCoefficientResultName = "Normalized Gini Coefficient (training)";
    3535    private const string TestNormalizedGiniCoefficientResultName = "Normalized Gini Coefficient (test)";
     36    private const string ClassificationPerformanceMeasuresResultName = "Classification Performance Measures";
    3637
    3738    public new IClassificationModel Model {
     
    6263      protected set { ((DoubleValue)this[TestNormalizedGiniCoefficientResultName].Value).Value = value; }
    6364    }
     65    public ClassificationPerformanceMeasuresResultCollection ClassificationPerformanceMeasures {
     66      get { return ((ClassificationPerformanceMeasuresResultCollection)this[ClassificationPerformanceMeasuresResultName].Value); }
     67      protected set { (this[ClassificationPerformanceMeasuresResultName].Value) = value; }
     68    }
    6469    #endregion
    6570
     
    7580      Add(new Result(TrainingNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the model on the training partition.", new DoubleValue()));
    7681      Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the model on the test partition.", new DoubleValue()));
     82      Add(new Result(ClassificationPerformanceMeasuresResultName, @"Classification performance measures.\n
     83                              In a multiclass classification all misclassifications of the negative class will be treated as true negatives except on positive class estimations.",
     84                            new ClassificationPerformanceMeasuresResultCollection()));
    7785    }
    7886
     
    8391      if (!this.ContainsKey(TestNormalizedGiniCoefficientResultName))
    8492        Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the model on the test partition.", new DoubleValue()));
     93      if (!this.ContainsKey(ClassificationPerformanceMeasuresResultName)) {
     94        Add(new Result(ClassificationPerformanceMeasuresResultName, @"Classification performance measures.\n
     95                              In a multiclass classification all misclassifications of the negative class will be treated as true negatives except on positive class estimations.",
     96                              new ClassificationPerformanceMeasuresResultCollection()));
     97        CalculateClassificationResults();
     98      }
    8599    }
    86100
     
    88102      double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values
    89103      double[] originalTrainingClassValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToArray();
     104
    90105      double[] estimatedTestClassValues = EstimatedTestClassValues.ToArray(); // cache values
    91106      double[] originalTestClassValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToArray();
     107
     108      var positiveClassName = ProblemData.PositiveClass;
     109      double positiveClassValue = ProblemData.GetClassValue(positiveClassName);
     110      ClassificationPerformanceMeasuresCalculator trainingPerformanceCalculator = new ClassificationPerformanceMeasuresCalculator(positiveClassName, positiveClassValue);
     111      ClassificationPerformanceMeasuresCalculator testPerformanceCalculator = new ClassificationPerformanceMeasuresCalculator(positiveClassName, positiveClassValue);
    92112
    93113      OnlineCalculatorError errorState;
     
    107127      TrainingNormalizedGiniCoefficient = trainingNormalizedGini;
    108128      TestNormalizedGiniCoefficient = testNormalizedGini;
     129
     130      trainingPerformanceCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues);
     131      if (trainingPerformanceCalculator.ErrorState == OnlineCalculatorError.None)
     132        ClassificationPerformanceMeasures.SetTrainingResults(trainingPerformanceCalculator);
     133
     134      testPerformanceCalculator.Calculate(originalTestClassValues, estimatedTestClassValues);
     135      if (testPerformanceCalculator.ErrorState == OnlineCalculatorError.None)
     136        ClassificationPerformanceMeasures.SetTestResults(testPerformanceCalculator);
    109137    }
    110138
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    111111
    112112
    113     public IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows) {
     113    public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    114114      return model.GetEstimatedValues(dataset, rows);
    115115    }
    116116
    117     public IEnumerable<double> GetEstimatedClassValues(Dataset dataset, IEnumerable<int> rows) {
     117    public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    118118      if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current classification model.");
    119119      foreach (var x in GetEstimatedValues(dataset, rows)) {
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    105105      TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;
    106106
    107       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    108       TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
    109       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    110       TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     107      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     108      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
     109      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     110      TestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    111111
    112112      double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/AccuracyMaximizationThresholdCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/NormalDistributionCutPointsThresholdCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/ThresholdCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727  [StorableClass]
    2828  [Item("Clustering Problem", "A general clustering problem.")]
    29   [Creatable("Problems")]
    3029  public class ClusteringProblem : DataAnalysisProblem<IClusteringProblemData>, IClusteringProblem {
    3130    [StorableConstructor]
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    8687    }
    8788
    88     public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables)
    89       : base(dataset, allowedInputVariables) {
     89    public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null)
     90      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    9091    }
    9192  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3838    protected const string TrainingPartitionParameterName = "TrainingPartition";
    3939    protected const string TestPartitionParameterName = "TestPartition";
     40    protected const string TransformationsParameterName = "Transformations";
    4041
    4142    #region parameter properites
     
    5152    public IFixedValueParameter<IntRange> TestPartitionParameter {
    5253      get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; }
     54    }
     55    public IFixedValueParameter<ReadOnlyItemList<ITransformation>> TransformationsParameter {
     56      get { return (IFixedValueParameter<ReadOnlyItemList<ITransformation>>)Parameters[TransformationsParameterName]; }
    5357    }
    5458    #endregion
     
    5963      get { return isEmpty; }
    6064    }
    61     public Dataset Dataset {
     65    public IDataset Dataset {
    6266      get { return DatasetParameter.Value; }
    6367    }
     
    8993    }
    9094
     95    public IEnumerable<ITransformation> Transformations {
     96      get { return TransformationsParameter.Value; }
     97    }
     98
    9199    public virtual bool IsTrainingSample(int index) {
    92100      return index >= 0 && index < Dataset.Rows &&
     
    111119    [StorableHook(HookType.AfterDeserialization)]
    112120    private void AfterDeserialization() {
     121      if (!Parameters.ContainsKey(TransformationsParameterName)) {
     122        Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", new ItemList<ITransformation>().AsReadOnly()));
     123        TransformationsParameter.Hidden = true;
     124      }
    113125      RegisterEventHandlers();
    114126    }
    115127
    116     protected DataAnalysisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables) {
     128    protected DataAnalysisProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null) {
    117129      if (dataset == null) throw new ArgumentNullException("The dataset must not be null.");
    118130      if (allowedInputVariables == null) throw new ArgumentNullException("The allowedInputVariables must not be null.");
     
    130142      int testPartitionEnd = dataset.Rows;
    131143
    132       Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", dataset));
     144      var transformationsList = new ItemList<ITransformation>(transformations ?? Enumerable.Empty<ITransformation>());
     145
     146      Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", (Dataset)dataset));
    133147      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly()));
    134148      Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd)));
    135149      Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
     150      Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly()));
     151
     152      TransformationsParameter.Hidden = true;
    136153
    137154      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
     
    144161      TrainingPartition.ValueChanged += new EventHandler(Parameter_ValueChanged);
    145162      TestPartition.ValueChanged += new EventHandler(Parameter_ValueChanged);
     163      TransformationsParameter.ValueChanged += new EventHandler(Parameter_ValueChanged);
    146164    }
    147165
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using HeuristicLab.Common;
     
    106107    }
    107108
     109    //mkommend avoid unnecessary event registration for result name changes
     110    protected override void RegisterItemEvents(IEnumerable<IResult> items) { }
     111    protected override void DeregisterItemEvents(IEnumerable<IResult> items) { }
     112
    108113    #region INamedItem Members
    109114    [Storable]
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    2931  [StorableClass]
    3032  [Item("Constant Regression Model", "A model that always returns the same constant value regardless of the presented input data.")]
    31   public class ConstantRegressionModel : NamedItem, IRegressionModel {
     33  public class ConstantRegressionModel : NamedItem, IRegressionModel, IStringConvertibleValue {
    3234    [Storable]
    33     protected double constant;
     35    private double constant;
    3436    public double Constant {
    3537      get { return constant; }
     38      // setter not implemented because manipulation of the constant is not allowed
    3639    }
    3740
     
    4952      this.description = ItemDescription;
    5053      this.constant = constant;
     54      this.ReadOnly = true; // changing a constant regression model is not supported
    5155    }
    5256
    53     public IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows) {
     57    public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    5458      return rows.Select(row => Constant);
    5559    }
     
    5862      return new ConstantRegressionSolution(this, new RegressionProblemData(problemData));
    5963    }
     64
     65    public override string ToString() {
     66      return string.Format("Constant: {0}", GetValue());
     67    }
     68
     69    #region IStringConvertibleValue
     70    public bool ReadOnly { get; private set; }
     71    public bool Validate(string value, out string errorMessage) {
     72      throw new NotSupportedException(); // changing a constant regression model is not supported
     73    }
     74
     75    public string GetValue() {
     76      return string.Format("{0:E4}", constant);
     77    }
     78
     79    public bool SetValue(string value) {
     80      throw new NotSupportedException(); // changing a constant regression model is not supported
     81    }
     82
     83    public event EventHandler ValueChanged;
     84    #endregion
    6085  }
    6186}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    8080    }
    8181
    82     public IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows) {
     82    public IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(IDataset dataset, IEnumerable<int> rows) {
    8383      var estimatedValuesEnumerators = (from model in models
    8484                                        select model.GetEstimatedValues(dataset, rows).GetEnumerator())
     
    9595    #region IRegressionModel Members
    9696
    97     public IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows) {
     97    public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    9898      foreach (var estimatedValuesVector in GetEstimatedValueVectors(dataset, rows)) {
    9999        yield return estimatedValuesVector.Average();
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3535  [StorableClass]
    3636  [Item("Regression Ensemble Solution", "A regression solution that contains an ensemble of multiple regression models")]
    37   [Creatable("Data Analysis - Ensembles")]
     37  [Creatable(CreatableAttribute.Categories.DataAnalysisEnsembles, Priority = 100)]
    3838  public sealed class RegressionEnsembleSolution : RegressionSolutionBase, IRegressionEnsembleSolution {
    3939    private readonly Dictionary<int, double> trainingEvaluationCache = new Dictionary<int, double>();
     
    5050    }
    5151
     52    [Storable]
    5253    private readonly ItemCollection<IRegressionSolution> regressionSolutions;
    5354    public IItemCollection<IRegressionSolution> RegressionSolutions {
     
    6768    [StorableHook(HookType.AfterDeserialization)]
    6869    private void AfterDeserialization() {
    69       foreach (var model in Model.Models) {
    70         IRegressionProblemData problemData = (IRegressionProblemData)ProblemData.Clone();
    71         problemData.TrainingPartition.Start = trainingPartitions[model].Start;
    72         problemData.TrainingPartition.End = trainingPartitions[model].End;
    73         problemData.TestPartition.Start = testPartitions[model].Start;
    74         problemData.TestPartition.End = testPartitions[model].End;
    75 
    76         regressionSolutions.Add(model.CreateRegressionSolution(problemData));
     70      if (!regressionSolutions.Any()) {
     71        foreach (var model in Model.Models) {
     72          IRegressionProblemData problemData = (IRegressionProblemData)ProblemData.Clone();
     73          problemData.TrainingPartition.Start = trainingPartitions[model].Start;
     74          problemData.TrainingPartition.End = trainingPartitions[model].End;
     75          problemData.TestPartition.Start = testPartitions[model].Start;
     76          problemData.TestPartition.End = testPartitions[model].End;
     77
     78          regressionSolutions.Add(model.CreateRegressionSolution(problemData));
     79        }
    7780      }
    7881      RegisterRegressionSolutionsEventHandler();
     
    232235    }
    233236
    234     public IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows) {
     237    public IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(IDataset dataset, IEnumerable<int> rows) {
    235238      if (!Model.Models.Any()) yield break;
    236239      var estimatedValuesEnumerators = (from model in Model.Models
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727  [StorableClass]
    2828  [Item("Regression Problem", "A general regression problem.")]
    29   [Creatable("Problems")]
    3029  public class RegressionProblem : DataAnalysisProblem<IRegressionProblemData>, IRegressionProblem, IStorableContent {
    3130    public string Filename { get; set; }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    137137    }
    138138
    139     public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    140       : base(dataset, allowedInputVariables) {
     139    public RegressionProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null)
     140      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    141141      var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
    142142      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First()));
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3030  /// </summary>
    3131  [StorableClass]
    32   public abstract class RegressionSolution : RegressionSolutionBase {
     32  public class RegressionSolution : RegressionSolutionBase {
    3333    protected readonly Dictionary<int, double> evaluationCache;
    3434
     
    4242      evaluationCache = new Dictionary<int, double>(original.evaluationCache);
    4343    }
    44     protected RegressionSolution(IRegressionModel model, IRegressionProblemData problemData)
     44    public RegressionSolution(IRegressionModel model, IRegressionProblemData problemData)
    4545      : base(model, problemData) {
    4646      evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows);
     
    4848    }
    4949
     50    public override IDeepCloneable Clone(Cloner cloner) {
     51      return new RegressionSolution(this, cloner);
     52    }
    5053
    5154    public override IEnumerable<double> EstimatedValues {
     
    6063
    6164    public override IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows) {
    62       var rowsToEvaluate = rows.Except(evaluationCache.Keys);
     65      var rowsToEvaluate = rows.Where(row => !evaluationCache.ContainsKey(row));
    6366      var rowsEnumerator = rowsToEvaluate.GetEnumerator();
    6467      var valuesEnumerator = Model.GetEstimatedValues(ProblemData.Dataset, rowsToEvaluate).GetEnumerator();
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Common;
     
    3940    protected const string TrainingNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (training)";
    4041    protected const string TestNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (test)";
    41     protected const string TrainingMeanErrorResultName = "Mean error (training)";
    42     protected const string TestMeanErrorResultName = "Mean error (test)";
     42    protected const string TrainingRootMeanSquaredErrorResultName = "Root mean squared error (training)";
     43    protected const string TestRootMeanSquaredErrorResultName = "Root mean squared error (test)";
     44
     45    // BackwardsCompatibility3.3
     46    #region Backwards compatible code, remove with 3.5
     47    private const string TrainingMeanErrorResultName = "Mean error (training)";
     48    private const string TestMeanErrorResultName = "Mean error (test)";
     49    #endregion
     50
    4351
    4452    protected const string TrainingMeanSquaredErrorResultDescription = "Mean of squared errors of the model on the training partition";
     
    5260    protected const string TrainingNormalizedMeanSquaredErrorResultDescription = "Normalized mean of squared errors of the model on the training partition";
    5361    protected const string TestNormalizedMeanSquaredErrorResultDescription = "Normalized mean of squared errors of the model on the test partition";
    54     protected const string TrainingMeanErrorResultDescription = "Mean of errors of the model on the training partition";
    55     protected const string TestMeanErrorResultDescription = "Mean of errors of the model on the test partition";
     62    protected const string TrainingRootMeanSquaredErrorResultDescription = "Root mean of squared errors of the model on the training partition";
     63    protected const string TestRootMeanSquaredErrorResultDescription = "Root mean of squared errors of the model on the test partition";
    5664
    5765    public new IRegressionModel Model {
     
    111119      private set { ((DoubleValue)this[TestNormalizedMeanSquaredErrorResultName].Value).Value = value; }
    112120    }
    113     public double TrainingMeanError {
    114       get { return ((DoubleValue)this[TrainingMeanErrorResultName].Value).Value; }
    115       private set { ((DoubleValue)this[TrainingMeanErrorResultName].Value).Value = value; }
    116     }
    117     public double TestMeanError {
    118       get { return ((DoubleValue)this[TestMeanErrorResultName].Value).Value; }
    119       private set { ((DoubleValue)this[TestMeanErrorResultName].Value).Value = value; }
    120     }
     121    public double TrainingRootMeanSquaredError {
     122      get { return ((DoubleValue)this[TrainingRootMeanSquaredErrorResultName].Value).Value; }
     123      private set { ((DoubleValue)this[TrainingRootMeanSquaredErrorResultName].Value).Value = value; }
     124    }
     125    public double TestRootMeanSquaredError {
     126      get { return ((DoubleValue)this[TestRootMeanSquaredErrorResultName].Value).Value; }
     127      private set { ((DoubleValue)this[TestRootMeanSquaredErrorResultName].Value).Value = value; }
     128    }
     129
     130    // BackwardsCompatibility3.3
     131    #region Backwards compatible code, remove with 3.5
     132    private double TrainingMeanError {
     133      get {
     134        if (!ContainsKey(TrainingMeanErrorResultName)) return double.NaN;
     135        return ((DoubleValue)this[TrainingMeanErrorResultName].Value).Value;
     136      }
     137      set {
     138        if (ContainsKey(TrainingMeanErrorResultName))
     139          ((DoubleValue)this[TrainingMeanErrorResultName].Value).Value = value;
     140      }
     141    }
     142    private double TestMeanError {
     143      get {
     144        if (!ContainsKey(TestMeanErrorResultName)) return double.NaN;
     145        return ((DoubleValue)this[TestMeanErrorResultName].Value).Value;
     146      }
     147      set {
     148        if (ContainsKey(TestMeanErrorResultName))
     149          ((DoubleValue)this[TestMeanErrorResultName].Value).Value = value;
     150      }
     151    }
     152    #endregion
    121153    #endregion
    122154
     
    138170      Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, TrainingNormalizedMeanSquaredErrorResultDescription, new DoubleValue()));
    139171      Add(new Result(TestNormalizedMeanSquaredErrorResultName, TestNormalizedMeanSquaredErrorResultDescription, new DoubleValue()));
    140       Add(new Result(TrainingMeanErrorResultName, TrainingMeanErrorResultDescription, new DoubleValue()));
    141       Add(new Result(TestMeanErrorResultName, TestMeanErrorResultDescription, new DoubleValue()));
     172      Add(new Result(TrainingRootMeanSquaredErrorResultName, TrainingRootMeanSquaredErrorResultDescription, new DoubleValue()));
     173      Add(new Result(TestRootMeanSquaredErrorResultName, TestRootMeanSquaredErrorResultDescription, new DoubleValue()));
    142174    }
    143175
     
    145177    private void AfterDeserialization() {
    146178      // BackwardsCompatibility3.4
    147 
    148179      #region Backwards compatible code, remove with 3.5
    149 
    150180      if (!ContainsKey(TrainingMeanAbsoluteErrorResultName)) {
    151181        OnlineCalculatorError errorState;
     
    162192      }
    163193
    164       if (!ContainsKey(TrainingMeanErrorResultName)) {
    165         OnlineCalculatorError errorState;
    166         Add(new Result(TrainingMeanErrorResultName, "Mean of errors of the model on the training partition", new DoubleValue()));
    167         double trainingME = OnlineMeanErrorCalculator.Calculate(EstimatedTrainingValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices), out errorState);
    168         TrainingMeanError = errorState == OnlineCalculatorError.None ? trainingME : double.NaN;
    169       }
    170       if (!ContainsKey(TestMeanErrorResultName)) {
    171         OnlineCalculatorError errorState;
    172         Add(new Result(TestMeanErrorResultName, "Mean of errors of the model on the test partition", new DoubleValue()));
    173         double testME = OnlineMeanErrorCalculator.Calculate(EstimatedTestValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices), out errorState);
    174         TestMeanError = errorState == OnlineCalculatorError.None ? testME : double.NaN;
     194      if (!ContainsKey(TrainingRootMeanSquaredErrorResultName)) {
     195        OnlineCalculatorError errorState;
     196        Add(new Result(TrainingRootMeanSquaredErrorResultName, TrainingRootMeanSquaredErrorResultDescription, new DoubleValue()));
     197        double trainingMSE = OnlineMeanSquaredErrorCalculator.Calculate(EstimatedTrainingValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices), out errorState);
     198        TrainingRootMeanSquaredError = errorState == OnlineCalculatorError.None ? Math.Sqrt(trainingMSE) : double.NaN;
     199      }
     200
     201      if (!ContainsKey(TestRootMeanSquaredErrorResultName)) {
     202        OnlineCalculatorError errorState;
     203        Add(new Result(TestRootMeanSquaredErrorResultName, TestRootMeanSquaredErrorResultDescription, new DoubleValue()));
     204        double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(EstimatedTestValues, ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices), out errorState);
     205        TestRootMeanSquaredError = errorState == OnlineCalculatorError.None ? Math.Sqrt(testMSE) : double.NaN;
    175206      }
    176207      #endregion
     
    198229      TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    199230
    200       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    201       TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
    202       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    203       TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     231      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     232      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
     233      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     234      TestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    204235
    205236      double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     
    213244      TestNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? testNMSE : double.NaN;
    214245
    215       double trainingME = OnlineMeanErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    216       TrainingMeanError = errorState == OnlineCalculatorError.None ? trainingME : double.NaN;
    217       double testME = OnlineMeanErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    218       TestMeanError = errorState == OnlineCalculatorError.None ? testME : double.NaN;
     246      TrainingRootMeanSquaredError = Math.Sqrt(TrainingMeanSquaredError);
     247      TestRootMeanSquaredError = Math.Sqrt(TestMeanSquaredError);
     248
     249      // BackwardsCompatibility3.3
     250      #region Backwards compatible code, remove with 3.5
     251      if (ContainsKey(TrainingMeanErrorResultName)) {
     252        double trainingME = OnlineMeanErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     253        TrainingMeanError = errorState == OnlineCalculatorError.None ? trainingME : double.NaN;
     254      }
     255      if (ContainsKey(TestMeanErrorResultName)) {
     256        double testME = OnlineMeanErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     257        TestMeanError = errorState == OnlineCalculatorError.None ? testME : double.NaN;
     258      }
     259      #endregion
    219260    }
    220261  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/ConstantTimeSeriesPrognosisModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3939    public ConstantTimeSeriesPrognosisModel(double constant) : base(constant) { }
    4040
    41     public IEnumerable<IEnumerable<double>> GetPrognosedValues(Dataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
     41    public IEnumerable<IEnumerable<double>> GetPrognosedValues(IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
    4242      return horizons.Select(horizon => Enumerable.Repeat(Constant, horizon));
    4343    }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/TimeSeriesPrognosisAutoRegressiveModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    5858    }
    5959
    60     public IEnumerable<IEnumerable<double>> GetPrognosedValues(Dataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
     60    public IEnumerable<IEnumerable<double>> GetPrognosedValues(IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
    6161      var rowsEnumerator = rows.GetEnumerator();
    6262      var horizonsEnumerator = horizons.GetEnumerator();
     
    9191    }
    9292
    93     public IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows) {
     93    public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    9494      var targetVariables = dataset.GetReadOnlyDoubleValues(TargetVariable);
    9595      foreach (int row in rows) {
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727  [StorableClass]
    2828  [Item("Time-series Prognosis Problem", "A general time-series prognosis problem.")]
    29   [Creatable("Problems")]
    3029  public class TimeSeriesPrognosisProblem : DataAnalysisProblem<ITimeSeriesPrognosisProblemData>, ITimeSeriesPrognosisProblem {
    3130    [StorableConstructor]
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    15821582      TrainingPartition.Start = 50;
    15831583    }
    1584     public TimeSeriesPrognosisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    1585       : base(dataset, allowedInputVariables, targetVariable) {
     1584    public TimeSeriesPrognosisProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null)
     1585      : base(dataset, allowedInputVariables, targetVariable, transformations ?? Enumerable.Empty<ITransformation>()) {
    15861586      Parameters.Add(new FixedValueParameter<IntValue>(TrainingHorizonParameterName, "Specifies the horizon (how far the prognosis reaches in the future) for each training sample.", new IntValue(1)));
    15871587      Parameters.Add(new FixedValueParameter<IntValue>(TestHorizonParameterName, "Specifies the horizon (how far the prognosis reaches in the future) for each test sample.", new IntValue(1)));
     
    16211621    }
    16221622
     1623    protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     1624      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     1625      ITimeSeriesPrognosisProblemData timeseriesProblemData = problemData as ITimeSeriesPrognosisProblemData;
     1626      if (timeseriesProblemData == null)
     1627        throw new ArgumentException("The problem data is not a time-series problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     1628
     1629      var returnValue = base.IsProblemDataCompatible(problemData, out errorMessage);
     1630      //check targetVariable
     1631      if (problemData.InputVariables.All(var => var.Value != TargetVariable)) {
     1632        errorMessage = string.Format("The target variable {0} is not present in the new problem data.", TargetVariable)
     1633                       + Environment.NewLine + errorMessage;
     1634        return false;
     1635      }
     1636      return returnValue;
     1637    }
     1638
    16231639    public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
    16241640      TimeSeriesPrognosisProblemData timeSeriesProblemData = problemData as TimeSeriesPrognosisProblemData;
     
    16261642        throw new ArgumentException("The problem data is not a timeseries problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    16271643
     1644      var trainingDataStart = TrainingIndices.First();
     1645
    16281646      base.AdjustProblemDataProperties(problemData);
     1647
     1648      TestPartition.Start = trainingDataStart;
    16291649
    16301650      TrainingHorizon = timeSeriesProblemData.TrainingHorizon;
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    369369      OnlineCalculatorError errorState;
    370370      var problemData = Solution.ProblemData;
     371      if (!problemData.TrainingIndices.Any()) return;
    371372      var model = Solution.Model;
    372373      //mean model
     
    393394      double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    394395      PrognosisTrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
    395       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    396       PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
     396      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     397      PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
    397398      double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    398399      PrognosisTrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN;
     
    415416      OnlineCalculatorError errorState;
    416417      var problemData = Solution.ProblemData;
     418      if (!problemData.TestIndices.Any()) return;
    417419      var model = Solution.Model;
    418       //mean model
    419       double trainingMean = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).Average();
    420       var meanModel = new ConstantTimeSeriesPrognosisModel(trainingMean);
    421 
    422       //AR1 model
    423       double alpha, beta;
    424       IEnumerable<double> trainingStartValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices.Select(r => r - 1).Where(r => r > 0)).ToList();
    425       OnlineLinearScalingParameterCalculator.Calculate(problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices.Where(x => x > 0)), trainingStartValues, out alpha, out beta, out errorState);
    426       var AR1model = new TimeSeriesPrognosisAutoRegressiveModel(problemData.TargetVariable, new double[] { beta }, alpha);
    427 
    428420      var testHorizions = problemData.TestIndices.Select(r => Math.Min(testHorizon, problemData.TestPartition.End - r)).ToList();
    429421      IEnumerable<IEnumerable<double>> testTargetValues = problemData.TestIndices.Zip(testHorizions, Enumerable.Range).Select(r => problemData.Dataset.GetDoubleValues(problemData.TargetVariable, r)).ToList();
    430422      IEnumerable<IEnumerable<double>> testEstimatedValues = model.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList();
    431423      IEnumerable<double> testStartValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TestIndices.Select(r => r - 1).Where(r => r > 0)).ToList();
    432       IEnumerable<IEnumerable<double>> testMeanModelPredictions = meanModel.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList();
    433       IEnumerable<IEnumerable<double>> testAR1ModelPredictions = AR1model.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList();
    434424
    435425      IEnumerable<double> originalTestValues = testTargetValues.SelectMany(x => x).ToList();
     
    440430      double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    441431      PrognosisTestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    442       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    443       PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     432      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     433      PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    444434      double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    445435      PrognosisTestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN;
     
    453443      PrognosisTestWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate(testStartValues, testTargetValues, testEstimatedValues, out errorState);
    454444      PrognosisTestWeightedDirectionalSymmetry = errorState == OnlineCalculatorError.None ? PrognosisTestWeightedDirectionalSymmetry : 0.0;
    455       PrognosisTestTheilsUStatisticAR1 = OnlineTheilsUStatisticCalculator.Calculate(testStartValues, testTargetValues, testAR1ModelPredictions, testEstimatedValues, out errorState);
    456       PrognosisTestTheilsUStatisticAR1 = errorState == OnlineCalculatorError.None ? PrognosisTestTheilsUStatisticAR1 : double.PositiveInfinity;
    457       PrognosisTestTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(testStartValues, testTargetValues, testMeanModelPredictions, testEstimatedValues, out errorState);
    458       PrognosisTestTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? PrognosisTestTheilsUStatisticMean : double.PositiveInfinity;
     445
     446
     447      if (problemData.TrainingIndices.Any()) {
     448        //mean model
     449        double trainingMean = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).Average();
     450        var meanModel = new ConstantTimeSeriesPrognosisModel(trainingMean);
     451
     452        //AR1 model
     453        double alpha, beta;
     454        IEnumerable<double> trainingStartValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices.Select(r => r - 1).Where(r => r > 0)).ToList();
     455        OnlineLinearScalingParameterCalculator.Calculate(problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices.Where(x => x > 0)), trainingStartValues, out alpha, out beta, out errorState);
     456        var AR1model = new TimeSeriesPrognosisAutoRegressiveModel(problemData.TargetVariable, new double[] { beta }, alpha);
     457
     458        IEnumerable<IEnumerable<double>> testMeanModelPredictions = meanModel.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList();
     459        IEnumerable<IEnumerable<double>> testAR1ModelPredictions = AR1model.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList();
     460
     461        PrognosisTestTheilsUStatisticAR1 = OnlineTheilsUStatisticCalculator.Calculate(testStartValues, testTargetValues, testAR1ModelPredictions, testEstimatedValues, out errorState);
     462        PrognosisTestTheilsUStatisticAR1 = errorState == OnlineCalculatorError.None ? PrognosisTestTheilsUStatisticAR1 : double.PositiveInfinity;
     463        PrognosisTestTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(testStartValues, testTargetValues, testMeanModelPredictions, testEstimatedValues, out errorState);
     464        PrognosisTestTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? PrognosisTestTheilsUStatisticMean : double.PositiveInfinity;
     465      }
    459466    }
    460467  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    149149    protected void CalculateTimeSeriesResults() {
    150150      OnlineCalculatorError errorState;
    151       double trainingMean = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average();
     151      double trainingMean = ProblemData.TrainingIndices.Any() ? ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average() : double.NaN;
    152152      var meanModel = new ConstantTimeSeriesPrognosisModel(trainingMean);
    153153
     
    159159
    160160      #region Calculate training quality measures
    161       IEnumerable<double> trainingTargetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToList();
    162       IEnumerable<double> trainingEstimatedValues = EstimatedTrainingValues.ToList();
    163       IEnumerable<double> trainingMeanModelPredictions = meanModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TrainingIndices).ToList();
    164       IEnumerable<double> trainingAR1ModelPredictions = AR1model.GetEstimatedValues(ProblemData.Dataset, ProblemData.TrainingIndices).ToList();
    165 
    166       TrainingDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingEstimatedValues, out errorState);
    167       TrainingDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TrainingDirectionalSymmetry : 0.0;
    168       TrainingWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingEstimatedValues, out errorState);
    169       TrainingWeightedDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TrainingWeightedDirectionalSymmetry : 0.0;
    170       TrainingTheilsUStatisticAR1 = OnlineTheilsUStatisticCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingAR1ModelPredictions, trainingEstimatedValues, out errorState);
    171       TrainingTheilsUStatisticAR1 = errorState == OnlineCalculatorError.None ? TrainingTheilsUStatisticAR1 : double.PositiveInfinity;
    172       TrainingTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingMeanModelPredictions, trainingEstimatedValues, out errorState);
    173       TrainingTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? TrainingTheilsUStatisticMean : double.PositiveInfinity;
     161      if (ProblemData.TrainingIndices.Any()) {
     162        IEnumerable<double> trainingTargetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToList();
     163        IEnumerable<double> trainingEstimatedValues = EstimatedTrainingValues.ToList();
     164        IEnumerable<double> trainingMeanModelPredictions = meanModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TrainingIndices).ToList();
     165        IEnumerable<double> trainingAR1ModelPredictions = AR1model.GetEstimatedValues(ProblemData.Dataset, ProblemData.TrainingIndices).ToList();
     166
     167        TrainingDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingEstimatedValues, out errorState);
     168        TrainingDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TrainingDirectionalSymmetry : 0.0;
     169        TrainingWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingEstimatedValues, out errorState);
     170        TrainingWeightedDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TrainingWeightedDirectionalSymmetry : 0.0;
     171        TrainingTheilsUStatisticAR1 = OnlineTheilsUStatisticCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingAR1ModelPredictions, trainingEstimatedValues, out errorState);
     172        TrainingTheilsUStatisticAR1 = errorState == OnlineCalculatorError.None ? TrainingTheilsUStatisticAR1 : double.PositiveInfinity;
     173        TrainingTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingMeanModelPredictions, trainingEstimatedValues, out errorState);
     174        TrainingTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? TrainingTheilsUStatisticMean : double.PositiveInfinity;
     175      }
    174176      #endregion
    175177
    176178      #region Calculate test quality measures
    177       IEnumerable<double> testTargetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToList();
    178       IEnumerable<double> testEstimatedValues = EstimatedTestValues.ToList();
    179       IEnumerable<double> testMeanModelPredictions = meanModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TestIndices).ToList();
    180       IEnumerable<double> testAR1ModelPredictions = AR1model.GetEstimatedValues(ProblemData.Dataset, ProblemData.TestIndices).ToList();
    181 
    182       TestDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(testTargetValues.First(), testTargetValues, testEstimatedValues, out errorState);
    183       TestDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TestDirectionalSymmetry : 0.0;
    184       TestWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate(testTargetValues.First(), testTargetValues, testEstimatedValues, out errorState);
    185       TestWeightedDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TestWeightedDirectionalSymmetry : 0.0;
    186       TestTheilsUStatisticAR1 = OnlineTheilsUStatisticCalculator.Calculate(testTargetValues.First(), testTargetValues, testAR1ModelPredictions, testEstimatedValues, out errorState);
    187       TestTheilsUStatisticAR1 = errorState == OnlineCalculatorError.None ? TestTheilsUStatisticAR1 : double.PositiveInfinity;
    188       TestTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(testTargetValues.First(), testTargetValues, testMeanModelPredictions, testEstimatedValues, out errorState);
    189       TestTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? TestTheilsUStatisticMean : double.PositiveInfinity;
     179      if (ProblemData.TestIndices.Any()) {
     180        IEnumerable<double> testTargetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToList();
     181        IEnumerable<double> testEstimatedValues = EstimatedTestValues.ToList();
     182        IEnumerable<double> testMeanModelPredictions = meanModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TestIndices).ToList();
     183        IEnumerable<double> testAR1ModelPredictions = AR1model.GetEstimatedValues(ProblemData.Dataset, ProblemData.TestIndices).ToList();
     184
     185        TestDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(testTargetValues.First(), testTargetValues, testEstimatedValues, out errorState);
     186        TestDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TestDirectionalSymmetry : 0.0;
     187        TestWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate(testTargetValues.First(), testTargetValues, testEstimatedValues, out errorState);
     188        TestWeightedDirectionalSymmetry = errorState == OnlineCalculatorError.None ? TestWeightedDirectionalSymmetry : 0.0;
     189        TestTheilsUStatisticAR1 = OnlineTheilsUStatisticCalculator.Calculate(testTargetValues.First(), testTargetValues, testAR1ModelPredictions, testEstimatedValues, out errorState);
     190        TestTheilsUStatisticAR1 = errorState == OnlineCalculatorError.None ? TestTheilsUStatisticAR1 : double.PositiveInfinity;
     191        TestTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(testTargetValues.First(), testTargetValues, testMeanModelPredictions, testEstimatedValues, out errorState);
     192        TestTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? TestTheilsUStatisticMean : double.PositiveInfinity;
     193      }
    190194      #endregion
    191195    }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationEnsembleModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626    void Remove(IClassificationModel model);
    2727    IEnumerable<IClassificationModel> Models { get; }
    28     IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(Dataset dataset, IEnumerable<int> rows);
     28    IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(IDataset dataset, IEnumerable<int> rows);
    2929  }
    3030}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationEnsembleSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626    new IClassificationEnsembleModel Model { get; }
    2727    IItemCollection<IClassificationSolution> ClassificationSolutions { get; }
    28     IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(Dataset dataset, IEnumerable<int> rows);
     28    IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(IDataset dataset, IEnumerable<int> rows);
    2929  }
    3030}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323namespace HeuristicLab.Problems.DataAnalysis {
    2424  public interface IClassificationModel : IDataAnalysisModel {
    25     IEnumerable<double> GetEstimatedClassValues(Dataset dataset, IEnumerable<int> rows);
     25    IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows);
    2626    IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
    2727  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626
    2727    IEnumerable<string> ClassNames { get; }
     28    string PositiveClass { get; set; }
    2829    IEnumerable<double> ClassValues { get; }
    2930    int Classes { get; }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionClassificationModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3030    // class values and thresholds can only be assigned simultanously
    3131    void SetThresholdsAndClassValues(IEnumerable<double> thresholds, IEnumerable<double> classValues);
    32     IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows);
     32    IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows);
    3333
    3434    event EventHandler ThresholdsChanged;
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionClassificationSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionThresholdCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Clustering/IClusteringModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323namespace HeuristicLab.Problems.DataAnalysis {
    2424  public interface IClusteringModel : IDataAnalysisModel {
    25     IEnumerable<int> GetClusterValues(Dataset dataset, IEnumerable<int> rows);
     25    IEnumerable<int> GetClusterValues(IDataset dataset, IEnumerable<int> rows);
    2626  }
    2727}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Clustering/IClusteringProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Clustering/IClusteringProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Clustering/IClusteringSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisModel.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblem.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2929    bool IsEmpty { get; }
    3030
    31     Dataset Dataset { get; }
     31    IDataset Dataset { get; }
    3232    ICheckedItemList<StringValue> InputVariables { get; }
    3333    IEnumerable<string> AllowedInputVariables { get; }
     
    3939    IEnumerable<int> TestIndices { get; }
    4040
     41    IEnumerable<ITransformation> Transformations { get; }
     42
    4143    bool IsTrainingSample(int index);
    4244    bool IsTestSample(int index);
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisSolution.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisSolutionExporter.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDependencyCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IOnlineCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionEnsembleModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626    void Remove(IRegressionModel model);
    2727    IEnumerable<IRegressionModel> Models { get; }
    28     IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows);
     28    IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(IDataset dataset, IEnumerable<int> rows);
    2929  }
    3030}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionEnsembleSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727    new RegressionEnsembleProblemData ProblemData { get; set; }
    2828    IItemCollection<IRegressionSolution> RegressionSolutions { get; }
    29     IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows);
     29    IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(IDataset dataset, IEnumerable<int> rows);
    3030  }
    3131}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323namespace HeuristicLab.Problems.DataAnalysis {
    2424  public interface IRegressionModel : IDataAnalysisModel {
    25     IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows);
     25    IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows);
    2626    IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData);
    2727  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4141    double TrainingNormalizedMeanSquaredError { get; }
    4242    double TestNormalizedMeanSquaredError { get; }
     43    double TrainingRootMeanSquaredError { get; }
     44    double TestRootMeanSquaredError { get; }
    4345  }
    4446}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/IOnlineTimeSeriesCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/ITimeSeriesPrognosisModel.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323namespace HeuristicLab.Problems.DataAnalysis {
    2424  public interface ITimeSeriesPrognosisModel : IRegressionModel {
    25     IEnumerable<IEnumerable<double>> GetPrognosedValues(Dataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons);
     25    IEnumerable<IEnumerable<double>> GetPrognosedValues(IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons);
    2626    ITimeSeriesPrognosisSolution CreateTimeSeriesPrognosisSolution(ITimeSeriesPrognosisProblemData problemData);
    2727  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/ITimeSeriesPrognosisProblem.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/ITimeSeriesPrognosisProblemData.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/ITimeSeriesPrognosisSolution.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/AutoCorrelationCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/HoeffdingsDependenceCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRDependenceCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3333
    3434    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
    35       return Math.Sqrt(OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState));
     35      return OnlinePearsonsRCalculator.Calculate(originalValues, estimatedValues, out errorState);
    3636    }
    3737  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRSquaredDependenceCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3232
    3333    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
    34       return OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState);
     34      var r = OnlinePearsonsRCalculator.Calculate(originalValues, estimatedValues, out errorState);
     35      return r * r;
    3536    }
    3637  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/SpearmansRankCorrelationCoefficientCalculator.cs

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/NormalizedGiniCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineAccuracyCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineBoundedMeanSquaredErrorCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineCovarianceCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineDirectionalSymmetryCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineLinearScalingParameterCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMaxAbsoluteErrorCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsoluteErrorCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsolutePercentageErrorCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAndVarianceCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanErrorCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanSquaredErrorCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineNormalizedMeanSquaredErrorCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlinePearsonsRSquaredCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
     27  [Obsolete("Use OnlinePearsonsRCalculator directly")]
    2728  public class OnlinePearsonsRSquaredCalculator : IOnlineCalculator {
    28     private OnlineCovarianceCalculator covCalculator = new OnlineCovarianceCalculator();
    29     private OnlineMeanAndVarianceCalculator sxCalculator = new OnlineMeanAndVarianceCalculator();
    30     private OnlineMeanAndVarianceCalculator syCalculator = new OnlineMeanAndVarianceCalculator();
     29    private readonly OnlinePearsonsRCalculator rCalculator = new OnlinePearsonsRCalculator();
    3130
    3231    public double RSquared {
    3332      get {
    34         double xVar = sxCalculator.PopulationVariance;
    35         double yVar = syCalculator.PopulationVariance;
    36         if (xVar.IsAlmost(0.0) || yVar.IsAlmost(0.0)) {
    37           return 0.0;
    38         } else {
    39           double r = covCalculator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar));
    40           return r * r;
    41         }
     33        if (rCalculator.ErrorState != OnlineCalculatorError.None) return 0.0;
     34        else return rCalculator.R * rCalculator.R;
    4235      }
    4336    }
     
    4740    #region IOnlineCalculator Members
    4841    public OnlineCalculatorError ErrorState {
    49       get { return covCalculator.ErrorState | sxCalculator.PopulationVarianceErrorState | syCalculator.PopulationVarianceErrorState; }
     42      get { return rCalculator.ErrorState; }
    5043    }
    5144    public double Value {
     
    5346    }
    5447    public void Reset() {
    55       covCalculator.Reset();
    56       sxCalculator.Reset();
    57       syCalculator.Reset();
     48      rCalculator.Reset();
    5849    }
    5950
    6051    public void Add(double x, double y) {
    61       // no need to check validity of values explicitly here as it is checked in all three evaluators
    62       covCalculator.Add(x, y);
    63       sxCalculator.Add(x);
    64       syCalculator.Add(y);
     52      rCalculator.Add(x, y);
    6553    }
    6654
     
    6856
    6957    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    70       IEnumerator<double> firstEnumerator = first.GetEnumerator();
    71       IEnumerator<double> secondEnumerator = second.GetEnumerator();
    72       OnlinePearsonsRSquaredCalculator rSquaredCalculator = new OnlinePearsonsRSquaredCalculator();
    73 
    74       // always move forward both enumerators (do not use short-circuit evaluation!)
    75       while (firstEnumerator.MoveNext() & secondEnumerator.MoveNext()) {
    76         double original = firstEnumerator.Current;
    77         double estimated = secondEnumerator.Current;
    78         rSquaredCalculator.Add(original, estimated);
    79         if (rSquaredCalculator.ErrorState != OnlineCalculatorError.None) break;
    80       }
    81 
    82       // check if both enumerators are at the end to make sure both enumerations have the same length
    83       if (rSquaredCalculator.ErrorState == OnlineCalculatorError.None &&
    84            (secondEnumerator.MoveNext() || firstEnumerator.MoveNext())) {
    85         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    86       } else {
    87         errorState = rSquaredCalculator.ErrorState;
    88         return rSquaredCalculator.RSquared;
    89       }
     58      var r = OnlinePearsonsRCalculator.Calculate(first, second, out errorState);
     59      return r * r;
    9060    }
    9161  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineTheilsUStatisticCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineWeightedDirectionalSymmetryCalculator.cs

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Plugin.cs.frame

    r10553 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis {
    28   [Plugin("HeuristicLab.Problems.DataAnalysis","Provides base classes for data analysis tasks.", "3.4.5.$WCREV$")]
     28  [Plugin("HeuristicLab.Problems.DataAnalysis","Provides base classes for data analysis tasks.", "3.4.8.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.ALGLIB","3.7.0")]
     
    3737  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3838  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    39   [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
     39  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 
    4040  public class HeuristicLabProblemsDataAnalysisPlugin : PluginBase {
    4141  }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Properties/AssemblyInfo.cs.frame

    r10556 r13083  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3131[assembly: AssemblyCompany("")]
    3232[assembly: AssemblyProduct("HeuristicLab")]
    33 [assembly: AssemblyCopyright("(c) 2002-2013 HEAL")]
     33[assembly: AssemblyCopyright("(c) 2002-2015 HEAL")]
    3434[assembly: AssemblyTrademark("")]
    3535[assembly: AssemblyCulture("")]
     
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.4.0.0")]
    55 [assembly: AssemblyFileVersion("3.4.5.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.4.8.$WCREV$")]
Note: See TracChangeset for help on using the changeset viewer.