Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9494


Ignore:
Timestamp:
05/14/13 16:54:01 (12 years ago)
Author:
sforsten
Message:

#1980:

  • renamed algorithm Learning Classifier System to XCS
  • DecisionListSolution and XCSSolution show more information
  • VariableVectorClassificationProblemData can now also import datasets where the last variable is not the target variable
Location:
branches/LearningClassifierSystems
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Algorithms.LearningClassifierSystems/3.3/LearningClassifierSystem.cs

    r9467 r9494  
    3838  /// A learning classifier system.
    3939  /// </summary>
    40   [Item("Learning Classifier System", "A genetic algorithm.")]
     40  [Item("XCS", "A learning classifier system")]
    4141  [Creatable("Algorithms")]
    4242  [StorableClass]
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.ConditionActionEncoding/3.3/XCSSolution.cs

    r9194 r9494  
    3737    private const string TrainingAccuracyResultName = "Accuracy (training)";
    3838    private const string TestAccuracyResultName = "Accuracy (test)";
     39    private const string NumberOfMacroClassifiersName = "Number of Macroclassifiers";
    3940
    4041    public string Filename { get; set; }
     
    4748      get { return ((DoubleValue)this[TestAccuracyResultName].Value).Value; }
    4849      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; }
    4954    }
    5055
     
    97102      Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue()));
    98103      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)));
    99105
    100106      problemData.Changed += new EventHandler(ProblemData_Changed);
     
    104110
    105111    private void RecalculateResults() {
     112      NumberOfMacroClassifiers = Model.ClassifierCount;
    106113      var originalTrainingCondition = ProblemData.FetchInput(ProblemData.TrainingIndices);
    107114      var originalTestCondition = ProblemData.FetchInput(ProblemData.TestIndices);
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/DecisionListSolution.cs

    r9475 r9494  
    4040    private const string TrainingNumberOfAliveRulesName = "Number of alive rules (training)";
    4141    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)";
    4344    private const string TrainingTheoryLengthName = "Theory Length (training)";
    4445    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";
    4549
    4650    public double TrainingAccuracy {
     
    6771      get { return ((DoubleValue)this[TrainingExceptionsLengthName].Value).Value; }
    6872      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; }
    6993    }
    7094
     
    122146      Add(new Result(TrainingTheoryLengthName, "", new DoubleValue()));
    123147      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)));
    124153
    125154      problemData.Changed += new EventHandler(ProblemData_Changed);
     
    132161
    133162    private void RecalculateResults() {
     163      DefaultRule = Model.DefaultAction;
     164      Rules = new ItemList<Rule>(Model.Rules);
     165      NumberOfRules = Model.RuleSetSize;
    134166      var originalTrainingCondition = ProblemData.FetchInput(ProblemData.TrainingIndices);
    135167      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;
    143178
    144179      var originalTrainingAction = ProblemData.FetchAction(ProblemData.TrainingIndices);
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/ConditionActionClassificationProblemData.cs

    r9411 r9494  
    128128      if (allowedConditionVariables == null) throw new ArgumentNullException("The allowedActionVariables must not be null.");
    129129
    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);
    132131      foreach (StringValue x in actionVariables) {
    133132        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) {
    134136        conditionVariables.SetItemCheckedState(x, allowedConditionVariables.Contains(x.Value));
    135137      }
     
    149151
    150152      RegisterParameterEvents();
     153    }
     154
     155    protected virtual CheckedItemList<StringValue> CheckVariablesForPossibleTargetVariables(DataAnalysis.Dataset dataset) {
     156      return new CheckedItemList<StringValue>(dataset.VariableNames.Select(x => new StringValue(x)));
    151157    }
    152158
  • branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblemData.cs

    r9475 r9494  
    7474    public VariableVectorClassificationProblemData(Dataset dataset, IEnumerable<string> allowedConditionVariables, IEnumerable<string> allowedActionVariables) :
    7575      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)));
    7777      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);
    7883    }
    7984
     
    8186      var conditionVariables = GetVariablesOfDataSet(dataset, allowedConditionVariables);
    8287      var actionVariables = GetVariablesOfDataSet(dataset, allowedActionVariables);
    83       if (actionVariables.Count() == 0 || !actionVariables.All(x => x is IActionVariable)) {
     88      if (!actionVariables.All(x => x is IActionVariable)) {
    8489        throw new ArgumentException("Action variable can not be empty and all action variables have to be of type int or string.");
    8590      }
     
    8792    }
    8893
    89     private IEnumerable<Encodings.VariableVector.IVariable> GetVariablesOfDataSet(DataAnalysis.Dataset dataset, IEnumerable<string> allowedVariables) {
     94    private IEnumerable<Encodings.VariableVector.IVariable> GetVariablesOfDataSet(Dataset dataset, IEnumerable<string> allowedVariables) {
    9095      var variables = new List<HeuristicLab.Encodings.VariableVector.IVariable>();
    9196      foreach (var variableName in allowedVariables) {
Note: See TracChangeset for help on using the changeset viewer.