title: Looping to calculate False Acceptance Rate (FAR) in python
body: <p>Now, I am working to calculate False Acceptance Rate (FAR). I have a dataset that are collected from 5 person. To calculate FAR, we can use formula following below:</p>
  
  <pre><code>FAR = Number acceptance of impostors / total number of impostors
  </code></pre>
  
  <p>In this case I compare the template and testing data by using euclidean distance like following below to obtain the number acceptance of importors:</p>
  
  <p><strong>stage 1</strong></p>
  
  <pre><code> person 1 --&gt;    person 2
                   person 3
                   person 4
                   person 5
  </code></pre>
  
  <p><strong>stage 2</strong></p>
  
  <pre><code>person 2 --&gt;    person 1
                  person 3
                  person 4
                  person 5
  </code></pre>
  
  <p><strong>stage 3</strong></p>
  
  <pre><code>  person 3--&gt;   person 1
                  person 2
                  person 4
                  person 5
  </code></pre>
  
  <p><strong>stage 4</strong></p>
  
  <pre><code>  person 4--&gt;   person 1
                  person 2
                  person 3
                  person 5
  </code></pre>
  
  <p><strong>stage 5</strong></p>
  
  <pre><code>  person 5--&gt;   person 1
                  person 2
                  person 3
                  person 4
  </code></pre>
  
  <p>I have done my looping for <code>stage 1</code>, however for <code>stage 2</code> up to <code>stage 5</code>, I cannot find how to looping them all together to provide one output that is number acceptace of impostors. My codes for <code>stage 1</code> are following below:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  from scipy.spatial import distance
  #load dataset
  dataset = pd.read_csv('data.csv', index_col=0)
  #template
  data_p1 = dataset[dataset['Person']==1]
  y = []
  #looping to compare template person 1 and testing person 2 until 37
  for x in xrange(2,6):
      #testing
      data_p2 = dataset[dataset['Person']==x]
      #distance function
      dst = distance.euclidean(data_p1 ,data_p2 )
      # example of threshold
      if dst &lt;= 0.05:
          y.append("wrong")
  
  y.count("wrong")
  0
  
  
  dataset.head()
      x1  x2  x3  x4  x5  Person
  
      0   1   55  0   10  1
      0   4   87  0   17  2
      0   3   68  0   14  3
      3   7   86  26  14  4
      0   2   82  0   10  5
  </code></pre>