Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/14 15:08:11 (10 years ago)
Author:
mkommend
Message:

#1758: Reimplemented functionality to load new problem data to data analysis solution and redesigned the according views.

  • Added setter for the target variable of regression and classification problem data.
  • Added functionality to check the compatibility of problem data.
  • Added functionality to adjust the properties of a problem data.
  • Added flowLayoutPanel with according buttons for loading a new problem data, simplifying and exporting data analysis solutions.
  • TradingProblemData currently throws a NotSupportedException when the properties should be adjusted.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r9456 r10540  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Text;
    2526using HeuristicLab.Collections;
    2627using HeuristicLab.Common;
     
    158159      if (listeners != null) listeners(this, EventArgs.Empty);
    159160    }
     161
     162    protected virtual bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     163      errorMessage = string.Empty;
     164      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     165
     166      //check allowed input variables
     167      StringBuilder message = new StringBuilder();
     168      var variables = new HashSet<string>(problemData.InputVariables.Select(x => x.Value));
     169      foreach (var item in AllowedInputVariables) {
     170        if (!variables.Contains(item))
     171          message.AppendLine("Input variable '" + item + "' is not present in the new problem data.");
     172      }
     173
     174      if (message.Length != 0) {
     175        errorMessage = message.ToString();
     176        return false;
     177      }
     178      return true;
     179
     180    }
     181
     182    public virtual void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
     183      DataAnalysisProblemData data = problemData as DataAnalysisProblemData;
     184      if (data == null) throw new ArgumentException("The problem data is not a data analysis problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     185
     186      string errorMessage;
     187      if (!data.IsProblemDataCompatible(this, out errorMessage)) {
     188        throw new InvalidOperationException(errorMessage);
     189      }
     190
     191      foreach (var inputVariable in InputVariables) {
     192        var variable = data.InputVariables.FirstOrDefault(i => i.Value == inputVariable.Value);
     193        InputVariables.SetItemCheckedState(inputVariable, variable != null && data.InputVariables.ItemChecked(variable));
     194      }
     195
     196      TrainingPartition.Start = TrainingPartition.End = 0;
     197      TestPartition.Start = 0;
     198      TestPartition.End = Dataset.Rows;
     199    }
    160200  }
    161201}
Note: See TracChangeset for help on using the changeset viewer.