wrong plot in logistic regression
<p>I am trying to implement logistic regression but I am receiving wrong plot.</p>

<pre><code>import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn import cross_validation
from sklearn.linear_model import LogisticRegression
sns.set()

x = (np.random.randint(2000, size=400)).reshape((400,1))
y = (np.random.randint(2, size=400)).reshape((400,1)).ravel()

x_train, x_test, y_train, y_test = cross_validation.train_test_split(x, y, test_size=0.4, random_state=0)

logistic_regr = LogisticRegression()
logistic_regr.fit(x_train, y_train)

fig, ax = plt.subplots()

ax.set(xlabel='x', ylabel='y')
ax.plot(x_test, logistic_regr.predict_proba(x_test), label='Logistic regr')
#ax.plot(x_test,logistic_regr.predict(x_test), label='Logistic regr')
ax.legend()
</code></pre>

<p>And I am receiving the following plot:</p>

<p><a href="https://i.stack.imgur.com/ewb7s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ewb7s.png" alt="enter image description here"></a></p>

<p>If I use:</p>

<p><code>ax.plot(x_test,logistic_regr.predict(x_test), label='Logistic regr')</code></p>

<p>I am receiving:</p>

<p><a href="https://i.stack.imgur.com/aBEKQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aBEKQ.png" alt="enter image description here"></a></p>