x1= data[:,:-1] x = np.insert(x1, index(0), values=1, axis=1) #to add a column of 1's in the features matrix