Changeset 4836
- Timestamp:
- 11/18/10 15:39:45 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/ClassificationProblemData.cs
r4781 r4836 232 232 Dataset.Name = Path.GetFileName(fileName); 233 233 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 236 241 if (!validTargetVariables.Any()) 237 242 throw new ArgumentException("Import of classification problem data was not successfull, because no target variable was found." + 238 " A target varia lbe 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."); 239 244 240 245 ((ConstrainedValueParameter<StringValue>)TargetVariableParameter).ValidValues.Clear(); … … 244 249 245 250 InputVariables = new CheckedItemList<StringValue>(variableNames).AsReadOnly(); 246 InputVariables.SetItemCheckedState(validTargetVariables.First(), false);251 if (TargetVariable != null) InputVariables.SetItemCheckedState(TargetVariable, false); 247 252 int middle = (int)(csvFileParser.Rows * 0.5); 248 253 TrainingSamplesEnd = new IntValue(middle);
Note: See TracChangeset
for help on using the changeset viewer.