title: one hot encode a binary value in numpy
body: <p>I have a numpy array that looks like the following: </p>
  
  <pre><code>array([[0],[1],[1]])
  </code></pre>
  
  <p>And I want it to be represented as the one hot encoded equivalent:</p>
  
  <pre><code>array([[1,0],[0,1],[0,1]])
  </code></pre>
  
  <p>Any body have any ideas? I tried using <a href="http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelBinarizer.html#sklearn.preprocessing.LabelBinarizer" rel="nofollow noreferrer">sklearn.preprocessing.LabelBinarizer</a> but this just re-produces the input.</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>As requested, here is the code using LabelBinarizer</p>
  
  <pre><code>from sklearn.preprocessing import LabelBinarizer
  
  train_y = np.array([[0],[1],[1]])
  lb = LabelBinarizer()
  lb.fit(train_y)
  label_vecs = lb.transform(train_y)
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>array([[0],[1],[1]])
  </code></pre>
  
  <p>Note that it does state in the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelBinarizer.html#sklearn.preprocessing.LabelBinarizer" rel="nofollow noreferrer">documentation</a> 'Binary targets transform to a column vector'</p>