title: Genetic Algorithm - Fitness function and Rule optimization
body: <p>Let's say I have a set of training examples where <code>A_i</code> is an attribute and the output is <code>Iris-setosa</code></p>
  
  <p>The values in the dataset are </p>
  
  <pre><code>A1, A2, A3, A4      outcome
  3   5   2   2       Iris-­setosa
  3   4   2   2       Iris­-setosa
  2   4   2   2       Iris­-setosa
  3   6   2   2       Iris­-setosa
  2   5   3   2       Iris­-setosa
  3   5   2   2       Iris­-setosa
  3   5   2   3       Iris­-setosa
  4   6   2   2       Iris­-setosa
  3   7   2   2       Iris­-setosa
  </code></pre>
  
  <p>from analysis the range of attribute are:</p>
  
  <pre><code>A1 ----&gt; [2,3,4]
  A2 ----&gt; [4,5,6,7]
  A3 ----&gt; [2,3]
  A4 ----&gt; [2,3]
  </code></pre>
  
  <p>I have defined:</p>
  
  <pre><code>A1 ----&gt; [Low(2),Medium(3),High(4)]
  A2 ----&gt; [Low(4,5),Medium(6),High(7)]
  A3 ----&gt; [Low(&lt;2),Medium(2),High(3)]
  A4 ----&gt; [Low(&lt;2),Medium(2),High(3)]
  </code></pre>
  
  <p>I have set like below:</p>
  
  <pre><code>A1,         A2,         A3,         A4          outcome
  Medium      Low         Medium      Medium      Iris-setosa     
  Medium      Low         Medium      Medium      Iris-setosa
  Low         Low         Medium      Medium      Iris-setosa
  Medium      Medium      Medium      Medium      Iris-setosa
  Low         Low         High        Medium      Iris-setosa
  Medium      Low         Medium      Medium      Iris-setosa
  Medium      Low         Medium      High        Iris-setosa
  High        Medium      Medium      Medium      Iris-setosa
  Medium      High        Medium      Medium      Iris-setosa
  </code></pre>
  
  <p>I know I have to define the <strong>fitness function</strong>. What is it for this problem? In my actual problem there are <strong>50</strong> training examples but this is a similar problem.</p>
  
  <p>How can I optimize rule by using <code>GA</code>? How can I encode?</p>
  
  <p>Suppose if I <strong>input (4,7,2,3)</strong>, how optimization can help me classify whether the input is <code>Iris-setosa</code> or not?</p>
  
  <p>Thank You for your patience.</p>