Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5601


Ignore:
Timestamp:
03/03/11 16:14:13 (14 years ago)
Author:
mkommend
Message:

#1418: Finished work on ProblemData.

Location:
branches/DataAnalysis Refactoring
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab 3.3.sln

    r5574 r5601  
    8585    {DF87C13E-A889-46FF-8153-66DCAA8C5674} = {DF87C13E-A889-46FF-8153-66DCAA8C5674}
    8686    {3D28463F-EC96-4D82-AFEE-38BE91A0CA00} = {3D28463F-EC96-4D82-AFEE-38BE91A0CA00}
     87    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198} = {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}
    8788    {678E2145-8152-4E19-9646-07D439D00301} = {678E2145-8152-4E19-9646-07D439D00301}
    8889    {49F28045-7B5F-411B-8D59-16C846FA26E0} = {49F28045-7B5F-411B-8D59-16C846FA26E0}
     
    373374EndProject
    374375Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic.Tests-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\Tests\HeuristicLab.Problems.DataAnalysis.Symbolic.Tests-3.4.csproj", "{2A976109-67B9-4FF0-89DE-A26A8307A1CE}"
     376EndProject
     377Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Views-3.4", "HeuristicLab.Problems.DataAnalysis.Views\3.4\HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj", "{3E9E8944-44FF-40BB-A622-3A4A7DD0F198}"
    375378EndProject
    376379Global
     
    17191722    {2A976109-67B9-4FF0-89DE-A26A8307A1CE}.Release|x86.ActiveCfg = Release|x86
    17201723    {2A976109-67B9-4FF0-89DE-A26A8307A1CE}.Release|x86.Build.0 = Release|x86
     1724    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     1725    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|Any CPU.Build.0 = Debug|Any CPU
     1726    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x64.ActiveCfg = Debug|x64
     1727    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x64.Build.0 = Debug|x64
     1728    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x86.ActiveCfg = Debug|x86
     1729    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x86.Build.0 = Debug|x86
     1730    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|Any CPU.ActiveCfg = Release|Any CPU
     1731    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|Any CPU.Build.0 = Release|Any CPU
     1732    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x64.ActiveCfg = Release|x64
     1733    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x64.Build.0 = Release|x64
     1734    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x86.ActiveCfg = Release|x86
     1735    {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x86.Build.0 = Release|x86
    17211736  EndGlobalSection
    17221737  GlobalSection(SolutionProperties) = preSolution
  • branches/DataAnalysis Refactoring/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs

    r5445 r5601  
    9292        if (value != reactOnValueToStringChangedAndValueItemImageChanged) {
    9393          reactOnValueToStringChangedAndValueItemImageChanged = value;
    94           if (reactOnValueToStringChangedAndValueItemImageChanged)
     94          if (reactOnValueToStringChangedAndValueItemImageChanged) {
    9595            RegisterValueEvents();
    96           else
     96            OnToStringChanged();
     97            OnItemImageChanged();
     98          } else
    9799            DeregisterValueEvents();
    98100        }
     
    187189      ((IValueParameter)this).Value = value;
    188190    }
    189    
     191
    190192    public event EventHandler ValueChanged;
    191193    protected virtual void OnValueChanged() {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r5586 r5601  
    5353    public static double[] Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) {
    5454      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    55       IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable.Value, rows);
     55      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5656      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    5757      double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues);
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5586 r5601  
    5353    public static double[] Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) {
    5454      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    55       IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable.Value, rows);
     55      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5656      double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues);
    5757      return new double[2] { r2, solution.Length };
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs

    r5586 r5601  
    5353    public static double Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) {
    5454      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    55       IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable.Value, rows);
     55      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5656      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    5757      return OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues);
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r5586 r5601  
    5353    public static double Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) {
    5454      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    55       IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable.Value, rows);
     55      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5656      return OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues);
    5757    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClassificationProblemData.cs

    r5579 r5601  
    2222using System;
    2323using System.Collections.Generic;
     24using System.IO;
    2425using System.Linq;
    2526using HeuristicLab.Common;
     27using HeuristicLab.Core;
     28using HeuristicLab.Data;
     29using HeuristicLab.Parameters;
    2630using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2731
    2832namespace HeuristicLab.Problems.DataAnalysis {
    2933  [StorableClass]
     34  [Item("ClassificationProblemData", "Represents an item containing all data defining a classification problem.")]
    3035  public class ClassificationProblemData : DataAnalysisProblemData, IClassificationProblemData {
     36    private const string TargetVariableParameterName = "TargetVariable";
     37    private const string ClassNamesParameterName = "ClassNames";
     38    private const string ClassificationPenaltiesParameterName = "ClassificationPenalties";
     39
    3140    #region default data
    3241    private static string[] defaultVariableNames = new string[] { "sample", "clump thickness", "cell size", "cell shape", "marginal adhesion", "epithelial cell size", "bare nuclei", "chromatin", "nucleoli", "mitoses", "class" };
     
    173182    #endregion
    174183
     184    #region parameter properties
     185    public IValueParameter<StringValue> TargetVariableParameter {
     186      get { return (IValueParameter<StringValue>)Parameters[TargetVariableParameterName]; }
     187    }
     188    public IFixedValueParameter<StringMatrix> ClassNamesParameter {
     189      get { return (IFixedValueParameter<StringMatrix>)Parameters[ClassNamesParameterName]; }
     190    }
     191    public IFixedValueParameter<DoubleMatrix> ClassificationPenaltiesParameter {
     192      get { return (IFixedValueParameter<DoubleMatrix>)Parameters[ClassificationPenaltiesParameterName]; }
     193    }
     194    #endregion
     195
    175196    #region propeties
    176     [Storable]
    177     private string targetVariable;
    178197    public string TargetVariable {
    179       get { return targetVariable; }
    180       set {
    181         if (!Dataset.VariableNames.Contains(value))
    182           throw new ArgumentException(string.Format("The target variable {0} is not present in the dataset", value));
    183         if (targetVariable != value) {
    184           targetVariable = value;
    185 
    186           InitializeTargetVariableDependentMembers();
    187           OnChanged();
     198      get { return TargetVariableParameter.Value.Value; }
     199    }
     200
     201    private List<double> classValues;
     202    public List<double> ClassValues {
     203      get {
     204        if (classValues == null) {
     205          classValues = Dataset.GetEnumeratedVariableValues(TargetVariableParameter.Value.Value).Distinct().ToList();
     206          classValues.Sort();
     207        }
     208        return classValues;
     209      }
     210    }
     211    IEnumerable<double> IClassificationProblemData.ClassValues {
     212      get { return ClassValues; }
     213    }
     214
     215    public int Classes {
     216      get { return ClassValues.Count; }
     217    }
     218
     219    private List<string> classNames;
     220    public List<string> ClassNames {
     221      get {
     222        if (classNames == null) {
     223          classNames = new List<string>();
     224          for (int i = 0; i < ClassNamesParameter.Value.Rows; i++)
     225            classNames.Add(ClassNamesParameter.Value[i, 0]);
     226        }
     227        return classNames;
     228      }
     229    }
     230    IEnumerable<string> IClassificationProblemData.ClassNames {
     231      get { return ClassNames; }
     232    }
     233
     234    private Dictionary<Tuple<double, double>, double> classificationPenaltiesCache = new Dictionary<Tuple<double, double>, double>();
     235    #endregion
     236
     237
     238    [StorableConstructor]
     239    protected ClassificationProblemData(bool deserializing) : base(deserializing) { }
     240    [StorableHook(HookType.AfterDeserialization)]
     241    private void AfterDeserialization() {
     242      RegisterParameterEvents();
     243    }
     244
     245    protected ClassificationProblemData(ClassificationProblemData original, Cloner cloner)
     246      : base(original, cloner) {
     247      RegisterParameterEvents();
     248    }
     249    public override IDeepCloneable Clone(Cloner cloner) { return new ClassificationProblemData(this, cloner); }
     250
     251    public ClassificationProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { }
     252    public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
     253      : base(dataset, allowedInputVariables) {
     254      var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
     255      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First()));
     256      Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix()));
     257      Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "", new DoubleMatrix()));
     258
     259      ResetTargetVariableDependentMembers();
     260      RegisterParameterEvents();
     261    }
     262
     263    private void ResetTargetVariableDependentMembers() {
     264      DergisterParameterEvents();
     265
     266      classNames = null;
     267      ((IStringConvertibleMatrix)ClassNamesParameter.Value).Columns = 1;
     268      ((IStringConvertibleMatrix)ClassNamesParameter.Value).Rows = ClassValues.Count;
     269      for (int i = 0; i < Classes; i++)
     270        ClassNamesParameter.Value[i, 0] = "Class " + ClassValues[i];
     271      ClassNamesParameter.Value.ColumnNames = new List<string>() { "ClassNames" };
     272      ClassNamesParameter.Value.RowNames = ClassValues.Select(s => "ClassValue: " + s);
     273
     274      classificationPenaltiesCache.Clear();
     275      ((ValueParameter<DoubleMatrix>)ClassificationPenaltiesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
     276      ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Rows = Classes;
     277      ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Columns = Classes;
     278      ClassificationPenaltiesParameter.Value.RowNames = ClassNames.Select(name => "Actual " + name);
     279      ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name);
     280      for (int i = 0; i < Classes; i++) {
     281        for (int j = 0; j < Classes; j++) {
     282          if (i != j) ClassificationPenaltiesParameter.Value[i, j] = 1;
     283          else ClassificationPenaltiesParameter.Value[i, j] = 0;
    188284        }
    189285      }
    190     }
    191 
    192     private List<double> classValues;
    193     [Storable]
    194     public IEnumerable<double> ClassValues {
    195       get { return classValues; }
    196       private set { classValues = new List<double>(value); }
    197     }
    198 
    199     public int Classes {
    200       get { return classValues.Count; }
    201     }
    202 
    203     private Dictionary<double, string> classValueClassNameMapping;
    204     private Dictionary<string, double> classNameClassValueMapping;
    205     [Storable(Name = "ClassNames")]
    206     private IEnumerable<KeyValuePair<double, string>> classValueClassNameMappingStorable {
    207       get { return classValueClassNameMapping; }
    208       set {
    209         classValueClassNameMapping = new Dictionary<double, string>();
    210         foreach (var mapping in value)
    211           classValueClassNameMapping[mapping.Key] = mapping.Value;
    212 
    213         classNameClassValueMapping = classValueClassNameMapping.ToDictionary(x => x.Value, x => x.Key);
    214       }
    215     }
    216     public IEnumerable<string> ClassNames {
    217       get { return classValueClassNameMapping.Values; }
    218     }
    219 
    220     [Storable]
    221     private Dictionary<Tuple<double, double>, double> misclassificationMatrix;
    222     #endregion
    223 
    224 
    225     [StorableConstructor]
    226     protected ClassificationProblemData(bool deserializing) : base(deserializing) { }
    227     protected ClassificationProblemData(ClassificationProblemData original, Cloner cloner) : base(original, cloner) { }
    228     public override IDeepCloneable Clone(Cloner cloner) { return new ClassificationProblemData(this, cloner); }
    229 
    230     public ClassificationProblemData()
    231       : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) {
    232     }
    233 
    234     public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    235       : base(dataset, allowedInputVariables) {
    236       TargetVariable = targetVariable;
    237 
    238       InitializeTargetVariableDependentMembers();
    239     }
    240 
    241     private void InitializeTargetVariableDependentMembers() {
    242       classValues = Dataset.GetEnumeratedVariableValues(targetVariable).Distinct().ToList();
    243       classValues.Sort();
    244 
    245       classValueClassNameMapping = new Dictionary<double, string>();
    246       foreach (double classValue in ClassValues) {
    247         classValueClassNameMapping.Add(classValue, "Class " + classValue);
    248       }
    249       classNameClassValueMapping = classValueClassNameMapping.ToDictionary(x => x.Value, x => x.Key);
    250       OnClassNamesChanged();
    251 
    252       //set default misclassification matrix
    253       misclassificationMatrix = new Dictionary<Tuple<double, double>, double>();
    254       foreach (double classValue1 in ClassValues) {
    255         foreach (double classValue2 in ClassValues) {
    256           double penalty = 1.0;
    257           if (classValue1 == classValue2) penalty = 0.0;
    258           SetClassificationPenalty(classValue1, classValue1, penalty);
    259         }
    260       }
    261       OnClassificationPenaltyChanged();
     286      ((ValueParameter<DoubleMatrix>)ClassificationPenaltiesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = true;
     287      RegisterParameterEvents();
    262288    }
    263289
    264290    public string GetClassName(double classValue) {
    265       return classValueClassNameMapping[classValue];
     291      if (!ClassValues.Contains(classValue)) throw new ArgumentException();
     292      int index = ClassValues.IndexOf(classValue);
     293      return ClassNames[index];
    266294    }
    267295    public double GetClassValue(string className) {
    268       return classNameClassValueMapping[className];
     296      if (!ClassNames.Contains(className)) throw new ArgumentException();
     297      int index = ClassNames.IndexOf(className);
     298      return ClassValues[index];
    269299    }
    270300    public void SetClassName(double classValue, string className) {
    271301      if (!classValues.Contains(classValue)) throw new ArgumentException();
    272       if (classValueClassNameMapping[classValue] != className) {
    273         classValueClassNameMapping[classValue] = className;
    274         classNameClassValueMapping = classValueClassNameMapping.ToDictionary(x => x.Value, x => x.Key);
    275       }
     302      int index = ClassValues.IndexOf(classValue);
     303      ClassNames[index] = className;
     304      ClassNamesParameter.Value[index, 0] = className;
    276305    }
    277306
     
    281310    public double GetClassificationPenalty(double correctClassValue, double estimatedClassValue) {
    282311      var key = Tuple.Create(correctClassValue, estimatedClassValue);
    283       return misclassificationMatrix[key];
     312      if (!classificationPenaltiesCache.ContainsKey(key)) {
     313        int correctClassIndex = ClassValues.IndexOf(correctClassValue);
     314        int estimatedClassIndex = ClassValues.IndexOf(estimatedClassValue);
     315        classificationPenaltiesCache[key] = ClassificationPenaltiesParameter.Value[correctClassIndex, estimatedClassIndex];
     316      }
     317      return classificationPenaltiesCache[key];
    284318    }
    285319    public void SetClassificationPenalty(string correctClassName, string estimatedClassName, double penalty) {
     
    288322    public void SetClassificationPenalty(double correctClassValue, double estimatedClassValue, double penalty) {
    289323      var key = Tuple.Create(correctClassValue, estimatedClassValue);
    290       if (!misclassificationMatrix.ContainsKey(key) || misclassificationMatrix[key] != penalty) {
    291         misclassificationMatrix[key] = penalty;
    292         OnClassificationPenaltyChanged();
    293       }
    294     }
    295 
    296     public event EventHandler ClassNamesChanged;
    297     protected virtual void OnClassNamesChanged() {
    298       var handler = ClassNamesChanged;
    299       if (handler != null) handler(this, EventArgs.Empty);
    300     }
    301     public event EventHandler ClassificationPenaltyChanged;
    302     protected virtual void OnClassificationPenaltyChanged() {
    303       var handler = ClassificationPenaltyChanged;
    304       if (handler != null) handler(this, EventArgs.Empty);
    305     }
     324      int correctClassIndex = ClassValues.IndexOf(correctClassValue);
     325      int estimatedClassIndex = ClassValues.IndexOf(estimatedClassValue);
     326
     327      ClassificationPenaltiesParameter.Value[correctClassIndex, estimatedClassIndex] = penalty;
     328    }
     329
     330    #region events
     331    private void RegisterParameterEvents() {
     332      TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged);
     333      ClassNamesParameter.Value.Reset += new EventHandler(Parameter_ValueChanged);
     334      ClassNamesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged);
     335      ClassificationPenaltiesParameter.Value.Reset += new EventHandler(Parameter_ValueChanged);
     336      ClassificationPenaltiesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged);
     337    }
     338    private void DergisterParameterEvents() {
     339      TargetVariableParameter.ValueChanged -= new EventHandler(TargetVariableParameter_ValueChanged);
     340      ClassNamesParameter.Value.Reset -= new EventHandler(Parameter_ValueChanged);
     341      ClassNamesParameter.Value.ItemChanged -= new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged);
     342      ClassificationPenaltiesParameter.Value.Reset -= new EventHandler(Parameter_ValueChanged);
     343      ClassificationPenaltiesParameter.Value.ItemChanged -= new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged);
     344    }
     345
     346    private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) {
     347      classValues = null;
     348      ResetTargetVariableDependentMembers();
     349      OnChanged();
     350    }
     351    private void Parameter_ValueChanged(object sender, EventArgs e) {
     352      OnChanged();
     353    }
     354    private void MatrixParameter_ItemChanged(object sender, EventArgs<int, int> e) {
     355      OnChanged();
     356    }
     357    #endregion
     358
     359    #region Import from file
     360    public static ClassificationProblemData ImportFromFile(string fileName) {
     361      TableFileParser csvFileParser = new TableFileParser();
     362      csvFileParser.Parse(fileName);
     363
     364      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
     365      dataset.Name = Path.GetFileName(fileName);
     366
     367      ClassificationProblemData problemData = new ClassificationProblemData(dataset, dataset.VariableNames.Skip(1), dataset.VariableNames.First());
     368      problemData.Name = "Data imported from " + Path.GetFileName(fileName);
     369      return problemData;
     370    }
     371    #endregion
    306372  }
    307373}
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/DataAnalysisProblem.cs

    r5578 r5601  
    3333    where T : class, IDataAnalysisProblemData {
    3434    private const string ProblemDataParameterName = "ProblemData";
    35     private const string ProblemDataParameterDescription = "";
     35    private const string ProblemDataParameterDescription = "The data set, target variable and input variables of the data analysis problem.";
    3636    #region parameter properties
    3737    IParameter IDataAnalysisProblem.ProblemDataParameter {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/DataAnalysisProblemData.cs

    r5586 r5601  
    4141
    4242    #region parameter properites
    43     public IValueParameter<Dataset> DatasetParameter {
    44       get { return (IValueParameter<Dataset>)Parameters[DatasetParameterName]; }
     43    public IFixedValueParameter<Dataset> DatasetParameter {
     44      get { return (IFixedValueParameter<Dataset>)Parameters[DatasetParameterName]; }
    4545    }
    4646    public IFixedValueParameter<ICheckedItemCollection<StringValue>> InputVariablesParameter {
     
    6464    public Dataset Dataset {
    6565      get { return DatasetParameter.Value; }
    66       set { DatasetParameter.Value = value; }
    6766    }
    6867    public ICheckedItemCollection<StringValue> InputVariables {
     
    120119      int testPartitionEnd = dataset.Rows;
    121120
    122       Parameters.Add(new ValueParameter<Dataset>(DatasetParameterName, "", dataset));
     121      Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", dataset));
    123122      Parameters.Add(new FixedValueParameter<ICheckedItemCollection<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly()));
    124123      Parameters.Add(new FixedValueParameter<IntValue>(TrainingPartitionStartParameterName, "", new IntValue(trainingPartitionStart)));
     
    127126      Parameters.Add(new FixedValueParameter<IntValue>(TestPartitionEndParameterName, "", new IntValue(testPartitionEnd)));
    128127
     128      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
    129129      RegisterEventHandlers();
    130130    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationProblemData.cs

    r5559 r5601  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423namespace HeuristicLab.Problems.DataAnalysis {
    2524  public interface IClassificationProblemData : IDataAnalysisProblemData {
    26     string TargetVariable { get; set; }
     25    string TargetVariable { get; }
     26
    2727    IEnumerable<string> ClassNames { get; }
    2828    IEnumerable<double> ClassValues { get; }
     
    3737    void SetClassificationPenalty(string correctClassName, string estimatedClassName, double penalty);
    3838    void SetClassificationPenalty(double correctClassValue, double estimatedClassValue, double penalty);
    39 
    40     event EventHandler ClassNamesChanged;
    41     event EventHandler ClassificationPenaltyChanged;
    4239  }
    4340}
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r5586 r5601  
    2727namespace HeuristicLab.Problems.DataAnalysis {
    2828  public interface IDataAnalysisProblemData : IParameterizedNamedItem {
    29     Dataset Dataset { get; set; }
     29    Dataset Dataset { get; }
    3030    ICheckedItemCollection<StringValue> InputVariables { get; }
    3131    IEnumerable<string> AllowedInputVariables { get; }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r5586 r5601  
    2020#endregion
    2121
    22 using HeuristicLab.Data;
    2322namespace HeuristicLab.Problems.DataAnalysis {
    2423  public interface IRegressionProblemData : IDataAnalysisProblemData {
    25     StringValue TargetVariable { get; }
     24    string TargetVariable { get; }
    2625  }
    2726}
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/RegressionProblemData.cs

    r5586 r5601  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.IO;
     
    3132namespace HeuristicLab.Problems.DataAnalysis {
    3233  [StorableClass]
     34  [Item("RegressionProblemData", "Represents an item containing all data defining a regression problem.")]
    3335  public sealed class RegressionProblemData : DataAnalysisProblemData, IRegressionProblemData {
    3436    private const string TargetVariableParameterName = "TargetVariable";
     
    7880      get { return (IValueParameter<StringValue>)Parameters[TargetVariableParameterName]; }
    7981    }
    80     public StringValue TargetVariable {
    81       get { return TargetVariableParameter.Value; }
     82    public string TargetVariable {
     83      get { return TargetVariableParameter.Value.Value; }
     84    }
     85
     86    [StorableConstructor]
     87    private RegressionProblemData(bool deserializing) : base(deserializing) { }
     88    [StorableHook(HookType.AfterDeserialization)]
     89    private void AfterDeserialization() {
     90      RegisterParameterEvents();
    8291    }
    8392
    8493
    85     [StorableConstructor]
    86     private RegressionProblemData(bool deserializing) : base(deserializing) { }
    87     private RegressionProblemData(RegressionProblemData original, Cloner cloner) : base(original, cloner) { }
     94    private RegressionProblemData(RegressionProblemData original, Cloner cloner)
     95      : base(original, cloner) {
     96      RegisterParameterEvents();
     97    }
    8898    public override IDeepCloneable Clone(Cloner cloner) { return new RegressionProblemData(this, cloner); }
    8999
     
    94104    public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    95105      : base(dataset, allowedInputVariables) {
    96       Parameters.Add(new ConstrainedValueParameter<StringValue>("TargetVariable", new ItemSet<StringValue>(InputVariables), InputVariables.Where(x => x.Value == targetVariable).First()));
     106      var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
     107      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First()));
    97108    }
    98109
     110    private void RegisterParameterEvents() {
     111      TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged);
     112    }
     113    private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) {
     114      OnChanged();
     115    }
     116
     117    #region Import from file
    99118    public static RegressionProblemData ImportFromFile(string fileName) {
    100119      TableFileParser csvFileParser = new TableFileParser();
     
    108127      return problemData;
    109128    }
     129    #endregion
    110130  }
    111131}
  • branches/DataAnalysis Refactoring/HeuristicLab/3.3/Files.txt

    r5573 r5601  
    6262HeuristicLab.Problems.DataAnalysis.Classification.Views\3.3:HeuristicLab.Problems.DataAnalysis.Classification.Views-3.3.dll
    6363HeuristicLab.Problems.DataAnalysis.Regression\3.3:HeuristicLab.Problems.DataAnalysis.Regression-3.3.dll
    64 HeuristicLab.Problems.DataAnalysis.Regression\3.4:HeuristicLab.Problems.DataAnalysis.Regression-3.4.dll
    6564HeuristicLab.Problems.DataAnalysis.Symbolic\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll
    6665HeuristicLab.Problems.DataAnalysis.Symbolic.Classification\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.dll
    6766HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll
    6867HeuristicLab.Problems.DataAnalysis.Views\3.3:HeuristicLab.Problems.DataAnalysis.Views-3.3.dll
     68HeuristicLab.Problems.DataAnalysis.Views\3.4:HeuristicLab.Problems.DataAnalysis.Views-3.4.dll
    6969HeuristicLab.Problems.ExternalEvaluation\3.3:HeuristicLab.Problems.ExternalEvaluation-3.3.dll
    7070HeuristicLab.Problems.ExternalEvaluation.Views\3.3:HeuristicLab.Problems.ExternalEvaluation.Views-3.3.dll
Note: See TracChangeset for help on using the changeset viewer.