array numpy regression linear

124 views Asked by At

I have an numpy array that has 3 rows and 3 columns .Like this:

100  200  300  
233  699  999 
566  655  895

and I want to create a numpy array like this for my linear regression:

100  200  300   1
233  699  999   1
566  655  895   1

This my code:

X=np.hstack((x[:,0]),x[:,1]),x[:,2]) ,np.ones(x.shape[0])))

Please how can I edit my code to get my target?

1

There are 1 answers

0
Askold Ilvento On
  1. You may not break x apart in hstack
  2. You should put the 2-dimension shape in ones because the 1-dimension shape arrays are not what you expect.
X = np.hstack((x, np.ones((x.shape[0], 1))))