title: fisher's linear discriminant in Python
body: <p>I have the fisher's linear discriminant that i need to use it to reduce my examples A and B that are high dimensional matrices to simply 2D, that is exactly like LDA, each example has classes A and B, therefore if i was to have a third example they also have classes A and B, fourth, fifth and n examples would always have classes A and B, therefore i would like to separate them in a simple use of fisher's linear discriminant. Im pretty much new to machine learning, so i dont know how to separate my classes, i've been following the formula by eye and coding on the go. From what i was reading, i need to apply a linear transformation to my data so i can find a good threshold for it, but first i'd need to  find the maximization function. For such task, i managed to find Sw and Sb, but i don't know how to go from there...</p>
  <p><a href="https://i.stack.imgur.com/ASxO1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ASxO1.jpg" alt="enter image description here" /></a></p>
  <p>Where i also need to find the maximization function.</p>
  <p><a href="https://i.stack.imgur.com/lEu6B.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/lEu6B.jpg" alt="enter image description here" /></a></p>
  <p>That maximization function gives me an eigen value solution:</p>
  <p><a href="https://i.stack.imgur.com/1i7fl.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/1i7fl.jpg" alt="enter image description here" /></a></p>
  <p>What i have for each classes are matrices 5x2 of 2 examples. For instance:</p>
  <pre><code>Example 1 
  Class_A = [
  201, 103,
  40, 43,
  23, 50,
  12, 123,
  99, 78
  ]
  Class_B = [
     201, 129,
     114, 195,
     180, 90,
     69, 62,
     76, 90
  ]
  
  Example 2   
  Class_A = [
  68, 98,
  201, 203,
  78, 212,
  49, 5,
  204, 78
  ]   
  Class_B = [
     52, 19,
     220, 219,
     159, 195,
     99, 23,
     46, 50
  ]
  </code></pre>
  <p>I tried finding Sw for the example above like this:</p>
  <pre><code>Example_1_Class_A = np.dot(Example_1_Class_A,  np.transpose(Example_1_Class_A))
  Example_1_Class_B = np.dot(Example_1_Class_B,  np.transpose(Example_1_Class_B))
  
  Example_2_Class_A = np.dot(Example_2_Class_A,  np.transpose(Example_2_Class_A))
  Example_2_Class_B = np.dot(Example_2_Class_B,  np.transpose(Example_2_Class_B))
  
  Sw = sum([Example_1_Class_A, Example_1_Class_B, Example_2_Class_A, Example_2_Class_B], axis=0)
  </code></pre>
  <p>As for Sb, i tried like this:</p>
  <pre><code>Example_1_Class_A_mean = Example_1_Class_A.mean(axis=0)
  Example_1_Class_B_mean = Example_1_Class_B.mean(axis=0)
           
  Example_2_Class_A_mean = Example_2_Class_A.mean(axis=0)
  Example_2_Class_B_mean = Example_2_Class_B.mean(axis=0)
           
  Example_1_Class_A_Sb = np.dot(Example_1_Class_A_mean, np.transpose(Example_1_Class_A_mean))
  Example_1_Class_B_Sb = np.dot(Example_1_Class_B_mean, np.transpose(Example_1_Class_B_mean))
           
  Example_2_Class_A_Sb = np.dot(Example_2_Class_A_mean, np.transpose(Example_2_Class_A_mean))
  Example_2_Class_B_Sb = np.dot(Example_2_Class_B_mean, np.transpose(Example_2_Class_B_mean))
  Sb = sum([Example_1_Class_A_Sb, Example_1_Class_B_Sb, Example_2_Class_A_Sb, Example_2_Class_B_Sb], axis=0) 
  </code></pre>
  <p>The problem is, i have no idea what else to do with my Sw and Sb, i am completely lost. Basically, what i need to do is get from here to this:</p>
  <p><a href="https://i.stack.imgur.com/t2bh0.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/t2bh0.jpg" alt="enter image description here" /></a></p>
  <p>How for given Example A and Example B, do i separate a cluster only for classes As and only for classes b</p>