plot hyperplane (separator line) using weights of line and bias? (single layer perceptron)?
<p>i need to draw separator line  to separate male from female base on height and weight using output of single layer perceptron. </p>

<p>i have data.txt file that hold two features (height and weight) and gender where 0 indicates males and 1 indicates females</p>

<p>i.e:</p>

<pre><code>|---------------------|------------------|------|
|      150.5          |     5.2          |   1  |
|---------------------|------------------|------|
|      142.8          |     4.0          |   0  | 
|---------------------|------------------|------|
|      150.5          |     5.2          |   1  |
|---------------------|------------------|------|
|      190            |     5.7          |   0  |
|---------------------|------------------|------| 



import numpy as np
from sklearn import svm
import matplotlib.pyplot as plt
from sklearn.linear_model import perceptron
from pandas import *
import fileinput

f = fileinput.input('data.txt')

#height of females and males 
X_1 = []
#weight of female and males 
X_2 = []
#labels 0 males and 1 females 
Y = []
for line in f:
    temp = line.split(",")
    if str(temp[2]) == '0\n' :
        X_1.append(round(float(temp[0]),2))
        X_2.append(round(float(temp[1]),2))
        Y.append(0)
    else:
        X_1.append(round(float(temp[0]), 2))
        X_2.append(round(float(temp[1]), 2))
        Y.append(1)

print len(X_1)
print len(Y)
inputs = DataFrame({
'Height' : X_1,
'Weight' : X_2,
'Targets' : Y
})
colormap = np.array(['r', 'b'])


net = perceptron.Perceptron(n_iter=1000, verbose=0, random_state=None, fit_intercept=True, eta0=0.002)

# Train the perceptron object (net)
net.fit(inputs[['Height','Weight']],inputs['Targets'])
# Output the values
print "Coefficient 0 " + str(net.coef_[0, 0])
print "Coefficient 1 " + str(net.coef_[0, 1])
print "Bias " + str(net.intercept_)

plt.scatter(inputs.Height,inputs.Weight, c=colormap[inputs.Targets],s=20)

# Calc the hyperplane (decision boundary)
ymin, ymax = plt.ylim()
w = net.coef_[0]
a = -w[0] / w[1]
xx = np.linspace(ymin, ymax)
yy = a * xx - (net.intercept_[0]) / w[1]

# Plot the hyperplane
plt.plot(xx, yy, 'k-')
plt.show()
</code></pre>

<p>but my graph looks like this <a href="https://i.stack.imgur.com/mB5td.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mB5td.png" alt="graph with separator line"></a></p>

<p>whereas my actually graph without line looks like that. i do not know what i am doing wrong <a href="https://i.stack.imgur.com/cPQn1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cPQn1.png" alt="enter image description here"></a></p>