Changeset 4836


Ignore:
Timestamp:
11/18/10 15:39:45 (8 years ago)
Author:
mkommend
Message:

Corrected ordering of valid target variables (ticket #939).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/ClassificationProblemData.cs

    r4781 r4836  
    232232      Dataset.Name = Path.GetFileName(fileName);
    233233      var variableNames = Dataset.VariableNames.Select(x => new StringValue(x).AsReadOnly()).ToList();
    234       var validTargetVariables = variableNames.Select(variable => new { Variable = variable, DistinctValues = Dataset.GetVariableValues(variable.Value, 0, 50).Distinct().Count() })
    235          .OrderBy(x => x.DistinctValues).Where(x => x.DistinctValues <= MaximumClasses).Select(x => x.Variable);
     234
     235      var validTargetVariables = from v in variableNames
     236                                 let DistinctValues = Dataset.Rows > 50 ? Dataset.GetVariableValues(v.Value, 0, 50).Distinct().Count()
     237                                                                        : Dataset.GetVariableValues(v.Value).Distinct().Count()
     238                                 where DistinctValues < MaximumClasses
     239                                 select v;
     240
    236241      if (!validTargetVariables.Any())
    237242        throw new ArgumentException("Import of classification problem data was not successfull, because no target variable was found." +
    238           " A target varialbe must have at most " + MaximumClasses + " distinct values to be applicable to classification.");
     243          " A target variable must have at most " + MaximumClasses + " distinct values to be applicable to classification.");
    239244
    240245      ((ConstrainedValueParameter<StringValue>)TargetVariableParameter).ValidValues.Clear();
     
    244249
    245250      InputVariables = new CheckedItemList<StringValue>(variableNames).AsReadOnly();
    246       InputVariables.SetItemCheckedState(validTargetVariables.First(), false);
     251      if (TargetVariable != null) InputVariables.SetItemCheckedState(TargetVariable, false);
    247252      int middle = (int)(csvFileParser.Rows * 0.5);
    248253      TrainingSamplesEnd = new IntValue(middle);
Note: See TracChangeset for help on using the changeset viewer.