numpy reshape confusion with negative shape values
<p>Always confused how numpy reshape handle negative shape parameter, here is an example of code and output, could anyone explain what happens for reshape [-1, 1] here? Thanks.</p>

<p>Related document, using Python 2.7.</p>

<p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html" rel="nofollow">http://docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html</a></p>

<pre><code>import numpy as np
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import OneHotEncoder

S = np.array(['box','apple','car'])
le = LabelEncoder()
S = le.fit_transform(S)
print(S)
ohe = OneHotEncoder()
one_hot = ohe.fit_transform(S.reshape(-1,1)).toarray()
print(one_hot)

[1 0 2]
[[ 0.  1.  0.]
 [ 1.  0.  0.]
 [ 0.  0.  1.]]
</code></pre>