- Timestamp:
- 05/14/13 16:54:01 (11 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystem.cs
r9467 r9494 38 38 /// A learning classifier system. 39 39 /// </summary> 40 [Item(" Learning Classifier System", "A genetic algorithm.")]40 [Item("XCS", "A learning classifier system")] 41 41 [Creatable("Algorithms")] 42 42 [StorableClass] -
branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/XCSSolution.cs
r9194 r9494 37 37 private const string TrainingAccuracyResultName = "Accuracy (training)"; 38 38 private const string TestAccuracyResultName = "Accuracy (test)"; 39 private const string NumberOfMacroClassifiersName = "Number of Macroclassifiers"; 39 40 40 41 public string Filename { get; set; } … … 47 48 get { return ((DoubleValue)this[TestAccuracyResultName].Value).Value; } 48 49 private set { ((DoubleValue)this[TestAccuracyResultName].Value).Value = value; } 50 } 51 public int NumberOfMacroClassifiers { 52 get { return ((IntValue)this[NumberOfMacroClassifiersName].Value).Value; } 53 private set { ((IntValue)this[NumberOfMacroClassifiersName].Value).Value = value; } 49 54 } 50 55 … … 97 102 Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue())); 98 103 Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue())); 104 Add(new Result(NumberOfMacroClassifiersName, new IntValue(model.ClassifierCount))); 99 105 100 106 problemData.Changed += new EventHandler(ProblemData_Changed); … … 104 110 105 111 private void RecalculateResults() { 112 NumberOfMacroClassifiers = Model.ClassifierCount; 106 113 var originalTrainingCondition = ProblemData.FetchInput(ProblemData.TrainingIndices); 107 114 var originalTestCondition = ProblemData.FetchInput(ProblemData.TestIndices); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListSolution.cs
r9475 r9494 40 40 private const string TrainingNumberOfAliveRulesName = "Number of alive rules (training)"; 41 41 private const string TrainingAliveRulesName = "Alive Rules (training)"; 42 //private const string TestNumberOfAliveRules = "Number of alive rules (test)"; 42 private const string TestNumberOfAliveRulesName = "Number of alive rules (test)"; 43 private const string TestAliveRulesName = "Alive Rules (test)"; 43 44 private const string TrainingTheoryLengthName = "Theory Length (training)"; 44 45 private const string TrainingExceptionsLengthName = "Exceptions Length (training)"; 46 private const string DefaultRuleName = "Default Rule Action"; 47 private const string RulesName = "Rules"; 48 private const string NumberOfRulesName = "Number of Rules"; 45 49 46 50 public double TrainingAccuracy { … … 67 71 get { return ((DoubleValue)this[TrainingExceptionsLengthName].Value).Value; } 68 72 private set { ((DoubleValue)this[TrainingExceptionsLengthName].Value).Value = value; } 73 } 74 public int TestNumberOfAliveRules { 75 get { return ((IntValue)this[TestNumberOfAliveRulesName].Value).Value; } 76 private set { ((IntValue)this[TestNumberOfAliveRulesName].Value).Value = value; } 77 } 78 public ItemSet<Rule> TestAliveRules { 79 get { return (ItemSet<Rule>)this[TestAliveRulesName].Value; } 80 private set { this[TestAliveRulesName].Value = value; } 81 } 82 public IAction DefaultRule { 83 get { return (IAction)this[DefaultRuleName].Value; } 84 private set { this[DefaultRuleName].Value = value; } 85 } 86 public ItemList<Rule> Rules { 87 get { return (ItemList<Rule>)this[RulesName].Value; } 88 private set { this[RulesName].Value = value; } 89 } 90 public int NumberOfRules { 91 get { return ((IntValue)this[NumberOfRulesName].Value).Value; } 92 private set { ((IntValue)this[NumberOfRulesName].Value).Value = value; } 69 93 } 70 94 … … 122 146 Add(new Result(TrainingTheoryLengthName, "", new DoubleValue())); 123 147 Add(new Result(TrainingExceptionsLengthName, "", new DoubleValue())); 148 Add(new Result(TestNumberOfAliveRulesName, "", new IntValue())); 149 Add(new Result(TestAliveRulesName, "", new ItemSet<Rule>())); 150 Add(new Result(DefaultRuleName, model.DefaultAction)); 151 Add(new Result(RulesName, new ItemList<Rule>(model.Rules))); 152 Add(new Result(NumberOfRulesName, new IntValue(model.RuleSetSize))); 124 153 125 154 problemData.Changed += new EventHandler(ProblemData_Changed); … … 132 161 133 162 private void RecalculateResults() { 163 DefaultRule = Model.DefaultAction; 164 Rules = new ItemList<Rule>(Model.Rules); 165 NumberOfRules = Model.RuleSetSize; 134 166 var originalTrainingCondition = ProblemData.FetchInput(ProblemData.TrainingIndices); 135 167 var originalTestCondition = ProblemData.FetchInput(ProblemData.TestIndices); 136 ItemSet<Rule> aliveRules; 137 double theoryLength; 138 var estimatedTraining = Model.Evaluate(originalTrainingCondition, out aliveRules, out theoryLength); 139 TrainingNumberOfAliveRules = aliveRules.Count + (Model.DefaultAction != null ? 1 : 0); 140 TrainingAliveRules = aliveRules; 141 TrainingTheoryLength = theoryLength; 142 var estimatedTest = Model.Evaluate(originalTestCondition); 168 ItemSet<Rule> trainingAliveRules; 169 double trainingTheoryLength; 170 var estimatedTraining = Model.Evaluate(originalTrainingCondition, out trainingAliveRules, out trainingTheoryLength); 171 TrainingNumberOfAliveRules = trainingAliveRules.Count + (Model.DefaultAction != null ? 1 : 0); 172 TrainingAliveRules = trainingAliveRules; 173 TrainingTheoryLength = trainingTheoryLength; 174 ItemSet<Rule> testAliveRules; 175 var estimatedTest = Model.Evaluate(originalTestCondition, out testAliveRules); 176 TestNumberOfAliveRules = testAliveRules.Count + (Model.DefaultAction != null ? 1 : 0); 177 TestAliveRules = testAliveRules; 143 178 144 179 var originalTrainingAction = ProblemData.FetchAction(ProblemData.TrainingIndices); -
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/ConditionActionClassificationProblemData.cs
r9411 r9494 128 128 if (allowedConditionVariables == null) throw new ArgumentNullException("The allowedActionVariables must not be null."); 129 129 130 var actionVariables = new CheckedItemList<StringValue>(dataset.VariableNames.Select(x => new StringValue(x))); 131 var conditionVariables = new CheckedItemList<StringValue>(actionVariables); 130 var actionVariables = CheckVariablesForPossibleTargetVariables(dataset); 132 131 foreach (StringValue x in actionVariables) { 133 132 actionVariables.SetItemCheckedState(x, allowedActionVariables.Contains(x.Value)); 133 } 134 var conditionVariables = new CheckedItemList<StringValue>(dataset.VariableNames.Select(x => new StringValue(x))); 135 foreach (StringValue x in conditionVariables) { 134 136 conditionVariables.SetItemCheckedState(x, allowedConditionVariables.Contains(x.Value)); 135 137 } … … 149 151 150 152 RegisterParameterEvents(); 153 } 154 155 protected virtual CheckedItemList<StringValue> CheckVariablesForPossibleTargetVariables(DataAnalysis.Dataset dataset) { 156 return new CheckedItemList<StringValue>(dataset.VariableNames.Select(x => new StringValue(x))); 151 157 } 152 158 -
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblemData.cs
r9475 r9494 74 74 public VariableVectorClassificationProblemData(Dataset dataset, IEnumerable<string> allowedConditionVariables, IEnumerable<string> allowedActionVariables) : 75 75 base(dataset, allowedConditionVariables, allowedActionVariables) { 76 Parameters.Add(new ValueParameter<VariableVector>("SampleVariableVector", "", GenerateSampleVariableVector(dataset, allowedConditionVariables, allowedActionVariables)));76 Parameters.Add(new ValueParameter<VariableVector>("SampleVariableVector", "", GenerateSampleVariableVector(dataset, AllowedConditionVariables, AllowedActionVariables))); 77 77 Parameters.Add(new FixedValueParameter<PercentValue>("SpreadPercentage", "", new PercentValue(0.5))); 78 } 79 80 protected override CheckedItemList<StringValue> CheckVariablesForPossibleTargetVariables(Dataset dataset) { 81 var allVariables = GetVariablesOfDataSet(dataset, dataset.VariableNames).Where(v => v is StringVariable || v is IntVariable).Select(v => new StringValue(v.VariableName)); 82 return new CheckedItemList<StringValue>(allVariables); 78 83 } 79 84 … … 81 86 var conditionVariables = GetVariablesOfDataSet(dataset, allowedConditionVariables); 82 87 var actionVariables = GetVariablesOfDataSet(dataset, allowedActionVariables); 83 if ( actionVariables.Count() == 0 ||!actionVariables.All(x => x is IActionVariable)) {88 if (!actionVariables.All(x => x is IActionVariable)) { 84 89 throw new ArgumentException("Action variable can not be empty and all action variables have to be of type int or string."); 85 90 } … … 87 92 } 88 93 89 private IEnumerable<Encodings.VariableVector.IVariable> GetVariablesOfDataSet(Data Analysis.Dataset dataset, IEnumerable<string> allowedVariables) {94 private IEnumerable<Encodings.VariableVector.IVariable> GetVariablesOfDataSet(Dataset dataset, IEnumerable<string> allowedVariables) { 90 95 var variables = new List<HeuristicLab.Encodings.VariableVector.IVariable>(); 91 96 foreach (var variableName in allowedVariables) {
Note: See TracChangeset
for help on using the changeset viewer.