Changeset 9470 for branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification
- Timestamp:
- 05/08/13 15:46:53 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Problems.DecisionListClassification/3.3/DecisionListClassificationProblemData.cs
r9468 r9470 134 134 if (allowedConditionVariables == null) throw new ArgumentNullException("The allowedActionVariables must not be null."); 135 135 136 //var validTargetVariableValues = CheckVariablesForPossibleTargetVariables(dataset).Select(x => new StringValue(x).AsReadOnly()).ToList(); 137 var validTargetVariableValues = dataset.VariableNames.Select(x => new StringValue(x)); 136 var validTargetVariableValues = CheckVariablesForPossibleTargetVariables(dataset); 137 if (!validTargetVariableValues.Any()) { 138 throw new ArgumentException("No valid target variable found."); 139 } 140 // var validTargetVariableValues = dataset.VariableNames.Select(x => new StringValue(x)); 138 141 var target = validTargetVariableValues.Where(x => x.Value == targetVariable).DefaultIfEmpty(validTargetVariableValues.First()).First(); 139 142 140 var conditionVariables = new CheckedItemList<StringValue>(dataset. DoubleVariables.Select(x => new StringValue(x)));143 var conditionVariables = new CheckedItemList<StringValue>(dataset.VariableNames.Select(x => new StringValue(x))); 141 144 foreach (StringValue x in conditionVariables) { 142 145 conditionVariables.SetItemCheckedState(x, allowedConditionVariables.Contains(x.Value)); 146 } 147 if (!targetVariable.Equals(target.Value)) { 148 var helper = conditionVariables.FirstOrDefault(x => x.Value.Equals(target.Value)); 149 if (helper != null) { 150 conditionVariables.SetItemCheckedState(helper, false); 151 } 152 helper = conditionVariables.FirstOrDefault(x => x.Value.Equals(targetVariable)); 153 if (helper != null) { 154 conditionVariables.SetItemCheckedState(helper, true); 155 } 143 156 } 144 157 … … 159 172 160 173 RegisterParameterEvents(); 174 } 175 176 private IEnumerable<StringValue> CheckVariablesForPossibleTargetVariables(DataAnalysis.Dataset dataset) { 177 var possibleTargets = new List<StringValue>(); 178 foreach (var variable in dataset.VariableNames) { 179 var variableValues = dataset.GetValues(variable); 180 if (variableValues is List<string>) { 181 possibleTargets.Add(new StringValue(variable)); 182 } else if (variableValues is List<double>) { 183 var doubleValues = (variableValues as List<double>).Distinct(); 184 if (doubleValues.All(x => x % 1 == 0)) { 185 possibleTargets.Add(new StringValue(variable)); 186 } 187 } 188 } 189 return possibleTargets; 161 190 } 162 191 public override IDeepCloneable Clone(Cloner cloner) {
Note: See TracChangeset
for help on using the changeset viewer.