Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/14/13 15:23:17 (12 years ago)
Author:
sforsten
Message:

#1980:

  • added XCSSolution, XCSModel, XCSClassifier to represent the xcs classifier
  • XCSSolution also shows the current accuracy (training and test partition has to be added)
  • added XCSSolutionAnalyzer to create a XCSSolution during the run of the algorithm
  • added XCSModelView to show the xcs model
  • fixed a bug in XCSDeletionOperator (sometimes it deleted less classifiers than it should)
  • moved some parameter from ConditionActionClassificationProblem to ConditionActionClassificationProblemData
Location:
branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/HeuristicLab.Problems.ConditionActionClassification-3.3.csproj

    r9105 r9154  
    4040    <Reference Include="HeuristicLab.Collections-3.3">
    4141      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     42      <Private>False</Private>
    4243    </Reference>
    4344    <Reference Include="HeuristicLab.Common-3.3">
    4445      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     46      <Private>False</Private>
    4547    </Reference>
    4648    <Reference Include="HeuristicLab.Core-3.3">
    4749      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     50      <Private>False</Private>
    4851    </Reference>
    4952    <Reference Include="HeuristicLab.Data-3.3">
    5053      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     54      <Private>False</Private>
    5155    </Reference>
    52     <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    53     <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    54     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     56    <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     57      <Private>False</Private>
     58    </Reference>
     59    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     60      <Private>False</Private>
     61    </Reference>
     62    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     63      <Private>False</Private>
     64    </Reference>
    5565    <Reference Include="HeuristicLab.Parameters-3.3">
    5666      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     67      <Private>False</Private>
    5768    </Reference>
    5869    <Reference Include="HeuristicLab.Persistence-3.3">
    5970      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     71      <Private>False</Private>
    6072    </Reference>
    6173    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    6274      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     75      <Private>False</Private>
    6376    </Reference>
    64     <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     77    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     78      <Private>False</Private>
     79    </Reference>
    6580    <Reference Include="System" />
    6681    <Reference Include="System.Core" />
     
    7691    <Compile Include="Implementation\ConditionActionClassificationProblemData.cs" />
    7792    <Compile Include="Plugin.cs" />
    78     <Compile Include="Reinforcement\CombinedIntegerVectorClassifierFetcher.cs" />
    7993    <None Include="HeuristicLab.snk" />
    8094    <None Include="Properties\AssemblyInfo.cs.frame" />
     
    88102      <Project>{CE7163C5-BFFE-45F0-9BD0-E10EF24E8BD2}</Project>
    89103      <Name>HeuristicLab.Encodings.CombinedIntegerVectorEncoding-3.3</Name>
     104      <Private>False</Private>
    90105    </ProjectReference>
    91106    <ProjectReference Include="..\..\HeuristicLab.Encodings.ConditionActionEncoding\3.3\HeuristicLab.Encodings.ConditionActionEncoding-3.3.csproj">
    92107      <Project>{422FB262-0845-4969-8D16-12F057AA90B1}</Project>
    93108      <Name>HeuristicLab.Encodings.ConditionActionEncoding-3.3</Name>
     109      <Private>False</Private>
    94110    </ProjectReference>
    95111  </ItemGroup>
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblem.cs

    r9110 r9154  
    7676      get { return (IFixedValueParameter<IntValue>)Parameters["ThetaMinimalNumberOfActions"]; }
    7777    }
    78     //for test purposes
    79     public IFixedValueParameter<IntValue> LengthParameter {
    80       get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
    81     }
    82     public IFixedValueParameter<IntValue> ActionPartLengthParameter {
    83       get { return (IFixedValueParameter<IntValue>)Parameters["ActionPartLength"]; }
    84     }
    85     public IFixedValueParameter<IntMatrix> BoundsParameter {
    86       get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; }
    87     }
    8878    #endregion
    8979
     
    120110    }
    121111    IParameter IConditionActionProblem.ActionExecuterParameter { get { return ActionExecuterParameter; } }
    122     public CombinedIntegerVectorClassifierFetcher ClassifierFetcher {
     112    public ClassifierFetcher ClassifierFetcher {
    123113      get { return ClassifierFetcherParameter.Value; }
    124114    }
    125     public ValueParameter<CombinedIntegerVectorClassifierFetcher> ClassifierFetcherParameter {
    126       get { return (ValueParameter<CombinedIntegerVectorClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; }
     115    public ValueParameter<ClassifierFetcher> ClassifierFetcherParameter {
     116      get { return (ValueParameter<ClassifierFetcher>)Parameters[ClassifierFetcherParameterName]; }
    127117    }
    128118    IClassifierFetcher IConditionActionProblem.ClassifierFetcher { get { return ClassifierFetcher; } }
     
    150140    IParameter IConditionActionProblem.CoveringSolutionCreatorParameter {
    151141      get { return CoveringSolutionCreatorParameter; }
     142    }
     143    private XCSSolutionAnalyzer XCSSolutionAnalyzer {
     144      get { return Operators.OfType<XCSSolutionAnalyzer>().FirstOrDefault(); }
    152145    }
    153146    #endregion
     
    170163    public ConditionActionClassificationProblem(ConditionActionClassificationProblemData problemData, XCSEvaluator evaluator, UniformRandomCombinedIntegerVectorCreator solutionCreator, ICoveringSolutionCreator coveringSolutionCreator)
    171164      : base(evaluator, solutionCreator) {
    172       Parameters.Add(new FixedValueParameter<IntValue>("Length", "The operator to create a solution.", new IntValue(7)));
    173       Parameters.Add(new FixedValueParameter<IntValue>("ActionPartLength", "The operator to create a solution.", new IntValue(1)));
    174       int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 2 } };
    175       Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "The operator to create a solution.", new IntMatrix(elements)));
    176165      Parameters.Add(new ValueParameter<ConditionActionClassificationProblemData>("ProblemData", "", problemData));
    177166      Parameters.Add(new FixedValueParameter<DoubleValue>("PositiveReward", "", new DoubleValue(1000)));
     
    182171
    183172      Parameters.Add(new ValueParameter<IActionExecuter>(ActionExecuterParameterName, "", new ActionExecuter()));
    184       Parameters.Add(new ValueParameter<CombinedIntegerVectorClassifierFetcher>(ClassifierFetcherParameterName, "", new CombinedIntegerVectorClassifierFetcher()));
     173      Parameters.Add(new ValueParameter<ClassifierFetcher>(ClassifierFetcherParameterName, "", new ClassifierFetcher()));
    185174      Parameters.Add(new FixedValueParameter<ItemSet<IClassifier>>("PossibleActions"));
    186175      Parameters.Add(new FixedValueParameter<ItemSet<CombinedIntegerVector>>("PossibleActionsConcreteClass"));
     
    196185      Evaluator.InitialPredictionParameter.ActualName = "InitialPrediction";
    197186
    198       SolutionCreator.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;
    199       SolutionCreator.LengthParameter.ActualName = LengthParameter.Name;
    200       SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
     187      SolutionCreator.ActionPartLengthParameter.ActualName = ProblemData.ActionLengthParameter.Name;
     188      SolutionCreator.LengthParameter.ActualName = ProblemData.LengthParameter.Name;
     189      SolutionCreator.BoundsParameter.ActualName = ProblemData.BoundsParameter.Name;
    201190
    202191      coveringSolutionCreator.ChangeSymbolProbabilityParameter.ActualName = ChangeSymbolProbabilityInCoveringParameter.Name;
     
    204193      coveringSolutionCreator.CreatedClassifierParameter.ActualName = "CombinedIntegerVector";
    205194
    206       ClassifierFetcher.ActionPartLengthParameter.ActualName = ActionPartLengthParameter.Name;
    207       ClassifierFetcher.BoundsParameter.ActualName = BoundsParameter.Name;
    208195      ClassifierFetcher.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
    209196
     
    217204      ThetaMinimalNumberOfActions.Value = PossibleActions.Count;
    218205
    219       BoundsParameter.ValueChanged += new System.EventHandler(BoundsParameter_ValueChanged);
    220       LengthParameter.ValueChanged += new System.EventHandler(LengthParameter_ValueChanged);
    221       ActionPartLengthParameter.ValueChanged += new System.EventHandler(ActionPartLengthParameter_ValueChanged);
    222     }
    223 
    224     #region event handler
    225     private void ActionPartLengthParameter_ValueChanged(object sender, System.EventArgs e) {
     206      InitializeOperators();
     207
     208      problemData.Changed += new System.EventHandler(problemData_Changed);
     209    }
     210
     211    private void problemData_Changed(object sender, System.EventArgs e) {
    226212      SetPossibleActions();
    227213    }
    228     private void LengthParameter_ValueChanged(object sender, System.EventArgs e) {
    229       SetPossibleActions();
    230     }
    231     private void BoundsParameter_ValueChanged(object sender, System.EventArgs e) {
    232       SetPossibleActions();
    233     }
    234     #endregion
     214
     215    private void InitializeOperators() {
     216      Operators.Add(new XCSSolutionAnalyzer());
     217
     218      ParameterizeAnalyzers();
     219    }
     220
     221    private void ParameterizeAnalyzers() {
     222      if (XCSSolutionAnalyzer != null) {
     223        XCSSolutionAnalyzer.ClassifierParameter.ActualName = SolutionCreator.CombinedIntegerVectorParameter.ActualName;
     224        XCSSolutionAnalyzer.PredictionParameter.ActualName = Evaluator.PredictionParameter.ActualName;
     225        XCSSolutionAnalyzer.ErrorParameter.ActualName = Evaluator.ErrorParameter.ActualName;
     226        XCSSolutionAnalyzer.FitnessParameter.ActualName = Evaluator.FitnessParameter.ActualName;
     227        XCSSolutionAnalyzer.ExperienceParameter.ActualName = Evaluator.ExperienceParameter.ActualName;
     228        XCSSolutionAnalyzer.AverageActionSetSizeParameter.ActualName = Evaluator.AverageActionSetSizeParameter.ActualName;
     229        XCSSolutionAnalyzer.NumerosityParameter.ActualName = Evaluator.NumerosityParameter.ActualName;
     230        XCSSolutionAnalyzer.TimestampParameter.ActualName = Evaluator.TimestampParameter.ActualName;
     231        XCSSolutionAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     232        XCSSolutionAnalyzer.ResultsParameter.ActualName = "Results";
     233      }
     234    }
    235235
    236236    private void SetPossibleActions() {
    237237      //get bounds of action
    238       IntMatrix actionBounds = GetElementsOfBoundsForAction(BoundsParameter.Value, LengthParameter.Value.Value, ActionPartLengthParameter.Value.Value);
    239       int actionLength = ActionPartLengthParameter.Value.Value;
    240       int start = LengthParameter.Value.Value - actionLength;
     238      IntMatrix actionBounds = GetElementsOfBoundsForAction(ProblemData.Bounds, ProblemData.Length.Value, ProblemData.ActionLength.Value);
     239      int actionLength = ProblemData.ActionLength.Value;
     240      int start = ProblemData.Length.Value - actionLength;
    241241      int[] elements = new int[actionLength];
    242242      int[] curPos = new int[actionLength];
  • branches/LearningClassifierSystems/HeuristicLab.Problems.ConditionActionClassification/3.3/Implementation/ConditionActionClassificationProblemData.cs

    r9089 r9154  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Encodings.CombinedIntegerVectorEncoding;
    2829using HeuristicLab.Encodings.ConditionActionEncoding;
    2930using HeuristicLab.Parameters;
     
    5455      get { return (IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)Parameters["ActionVariables"]; }
    5556    }
     57    public IFixedValueParameter<IntValue> LengthParameter {
     58      get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }
     59    }
     60    public IFixedValueParameter<IntValue> ActionLengthParameter {
     61      get { return (IFixedValueParameter<IntValue>)Parameters["ActionLength"]; }
     62    }
     63    public IFixedValueParameter<IntMatrix> BoundsParameter {
     64      get { return (IFixedValueParameter<IntMatrix>)Parameters["Bounds"]; }
     65    }
    5666    #endregion
    5767
     
    7484      get { return ActionVariables.CheckedItems.Select(x => x.Value.Value); }
    7585    }
     86
     87    private IDictionary<int, IClassifier> fetchClassifiersCache = new Dictionary<int, IClassifier>();
    7688
    7789
     
    105117      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>("ActionVariables", "", actionVariables.AsReadOnly()));
    106118      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>("ConditionVariables", "", conditionVariables.AsReadOnly()));
     119      Parameters.Add(new FixedValueParameter<IntValue>("Length", "", new IntValue(7)));
     120      Parameters.Add(new FixedValueParameter<IntValue>("ActionLength", "", new IntValue(1)));
     121      int[,] elements = new int[,] { { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 2 } };
     122      Parameters.Add(new FixedValueParameter<IntMatrix>("Bounds", "", new IntMatrix(elements)));
    107123
    108124      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
    109125    }
     126
     127    public event EventHandler Changed;
     128    protected virtual void OnChanged() {
     129      var listeners = Changed;
     130      if (listeners != null) listeners(this, EventArgs.Empty);
     131    }
     132
     133    public IntValue Length {
     134      get { return LengthParameter.Value; }
     135    }
     136
     137    public IntValue ActionLength {
     138      get { return ActionLengthParameter.Value; }
     139    }
     140
     141    public IntMatrix Bounds {
     142      get { return BoundsParameter.Value; }
     143    }
     144
     145    public IClassifier FetchClassifier(int rowNumber) {
     146      if (!fetchClassifiersCache.ContainsKey(rowNumber)) {
     147        int[] elements = new int[Length.Value];
     148        var variableNamesList = Dataset.VariableNames.ToList();
     149        int elementIndex = 0;
     150        for (int i = 0; i < variableNamesList.Count; i++) {
     151          if (AllowedConditionVariables.Contains(variableNamesList[i])) {
     152            elements[elementIndex] = int.Parse(Dataset.GetValue(rowNumber, i));
     153            elementIndex++;
     154          }
     155        }
     156        for (int i = 0; i < variableNamesList.Count; i++) {
     157          if (AllowedActionVariables.Contains(variableNamesList[i])) {
     158            elements[elementIndex] = int.Parse(Dataset.GetValue(rowNumber, i));
     159            elementIndex++;
     160          }
     161        }
     162        if (elementIndex != Length.Value) {
     163          throw new ArgumentException("Length of classifier is not equal to the number of allowed condition + action variables.");
     164        }
     165        fetchClassifiersCache.Add(rowNumber, new CombinedIntegerVector(elements, ActionLengthParameter.Value.Value, BoundsParameter.Value));
     166      }
     167      return fetchClassifiersCache[rowNumber];
     168    }
    110169  }
    111170}
Note: See TracChangeset for help on using the changeset viewer.