Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/16 18:54:14 (8 years ago)
Author:
gkronber
Message:

created a feature branch for #2650 (support for categorical variables in symb reg) with a first set of changes

work in progress...

Location:
branches/symbreg-factors-2650
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r13761 r14232  
    168168      get { return variableValues.Where(p => p.Value is List<double>).Select(p => p.Key); }
    169169    }
     170
     171    public IEnumerable<string> StringVariables {
     172      get { return variableValues.Where(p => p.Value is List<string>).Select(p => p.Key); }
     173    }
     174
    170175    public IEnumerable<double> GetDoubleValues(string variableName) {
    171176      return GetValues<double>(variableName);
     
    189194      return GetValues<double>(variableName, rows);
    190195    }
     196
     197    public string GetStringValue(string variableName, int row) {
     198      var values = GetValues<string>(variableName);
     199      return values[row];
     200    }
     201
     202    public IEnumerable<string> GetStringValues(string variableName, IEnumerable<int> rows) {
     203      return GetValues<string>(variableName, rows);
     204    }
     205    public ReadOnlyCollection<string> GetReadOnlyStringValues(string variableName) {
     206      var values = GetValues<string>(variableName);
     207      return values.AsReadOnly();
     208    }
     209
    191210    private IEnumerable<T> GetValues<T>(string variableName, IEnumerable<int> rows) {
    192211      var values = GetValues<T>(variableName);
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r14185 r14232  
    131131    protected DataAnalysisProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null) {
    132132      if (dataset == null) throw new ArgumentNullException("The dataset must not be null.");
    133       if (allowedInputVariables == null) throw new ArgumentNullException("The allowedInputVariables must not be null.");
    134 
    135       if (allowedInputVariables.Except(dataset.DoubleVariables).Any())
    136         throw new ArgumentException("All allowed input variables must be present in the dataset and of type double.");
    137 
    138       var inputVariables = new CheckedItemList<StringValue>(dataset.DoubleVariables.Select(x => new StringValue(x)));
     133      if (allowedInputVariables == null) throw new ArgumentNullException("The allowed input variables must not be null.");
     134
     135      if (allowedInputVariables.Except(dataset.DoubleVariables).Except(dataset.StringVariables).Any())
     136        throw new ArgumentException("All allowed input variables must be present in the dataset and of type double or string.");
     137
     138      var inputVariables = new CheckedItemList<StringValue>(dataset.DoubleVariables.Concat(dataset.StringVariables).Select(x => new StringValue(x)));
    139139      foreach (StringValue x in inputVariables)
    140140        inputVariables.SetItemCheckedState(x, allowedInputVariables.Contains(x.Value));
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r14185 r14232  
    3030
    3131    IDataset Dataset { get; }
    32     ICheckedItemList<StringValue> InputVariables { get; }
     32    ICheckedItemList<StringValue> InputVariables { get; } // TODO: check all usages of InputVariables (distinguish between doubles and strings)
    3333    IEnumerable<string> AllowedInputVariables { get; }
    3434
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataset.cs

    r14185 r14232  
    3030    IEnumerable<string> VariableNames { get; }
    3131    IEnumerable<string> DoubleVariables { get; }
     32    IEnumerable<string> StringVariables { get; }
     33
     34    bool VariableHasType<T>(string variableName);
    3235
    3336    double GetDoubleValue(string variableName, int row);
     
    3639    ReadOnlyCollection<double> GetReadOnlyDoubleValues(string variableName);
    3740
     41    string GetStringValue(string variableName, int row);
    3842    IEnumerable<string> GetStringValues(string variableName);
     43    IEnumerable<string> GetStringValues(string variableName, IEnumerable<int> rows);
     44    ReadOnlyCollection<string> GetReadOnlyStringValues(string VariableName);
     45
    3946    IEnumerable<DateTime> GetDateTimeValues(string variableName);
    4047  }
Note: See TracChangeset for help on using the changeset viewer.