title: Convert NumPy array to 0 or 1 based on threshold
body: <p>I have an array below:</p>
  
  <pre><code>a=np.array([0.1, 0.2, 0.3, 0.7, 0.8, 0.9])
  </code></pre>
  
  <p>What I want is to convert this vector to a binary vector based on a threshold. 
  take threshold=0.5 as an example, element that greater than 0.5 convert to 1, otherwise 0.<br>
  The output vector should like this:</p>
  
  <pre><code>a_output = [0, 0, 0, 1, 1, 1]
  </code></pre>
  
  <p>How can I do this?</p>