title: How can you turn an index array into a mask array in Numpy?
body: <p>Is it possible to convert an array of indices to an array of ones and zeros, given the range?
  i.e. [2,3] -> [0, 0, 1, 1, 0], in range of 5</p>
  
  <p>I'm trying to automate something like this:</p>
  
  <pre><code>&gt;&gt;&gt; index_array = np.arange(200,300)
  array([200, 201, ... , 299])
  
  &gt;&gt;&gt; mask_array = ???           # some function of index_array and 500
  array([0, 0, 0, ..., 1, 1, 1, ... , 0, 0, 0])
  
  &gt;&gt;&gt; train(data[mask_array])    # trains with 200~299
  &gt;&gt;&gt; predict(data[~mask_array]) # predicts with 0~199, 300~499
  </code></pre>