0
$\begingroup$
X=([-0.71239066,  0.45181234, -0.04450308,  0.75376638])
y=([ 44.18419163, 135.39949674,  96.51318381, 159.05759577])
y_pred1 = ((78.35 * X) + b).reshape(4)

plt.scatter(X,y)
plt.plot(X,reg.predict(X),color='red',label='OLS')
plt.plot(X,y_pred1,color='#00a65a',label='b = {}'.format(b))
plt.plot(X,y_pred,color='#A3E4D7',label='b = 0')
plt.legend()
plt.show()

I am using Matplotlib to draw regression lines. here is equation

78.35 * X + 100.... here y line should be intercept at 100

78.35 * X + 40.... here y line should be intercepted at 40

78.35 * X + 0.... here y the line should be intercepted at 0

But it doesn't happend.It is hard for me to understand that why it happened.Please check picture for matlib result enter image description here

$\endgroup$
5
  • 3
    $\begingroup$ It would be helpful to see the code that you used to produce the plots $\endgroup$
    – Broele
    Commented Jul 4 at 15:36
  • $\begingroup$ please check code .Code use matlibplot library $\endgroup$
    – jass
    Commented Jul 5 at 14:56
  • $\begingroup$ Can you provide some working code? It's hard to determine the issue when the code is incomplete / can't be run. $\endgroup$
    – nwaldo
    Commented Jul 6 at 6:13
  • $\begingroup$ The code does not work as it is. I convertes Xand yinto numpy arrays and removed two of the 3 plot-commands to get it running. It showed me the correct line and not the line from your plot. Furthermore: these are not the y-values from your scatter plot. $\endgroup$
    – Broele
    Commented Jul 8 at 7:16
  • $\begingroup$ I honestly would like to help you, but if you ask what is wrong with a plot and then post code that does not produce this plot, how do you think we can answer the question. $\endgroup$
    – Broele
    Commented Jul 8 at 7:18

0

Browse other questions tagged or ask your own question.