You can use eigenvector of covariance matrix associated with the largest eigenvalue to perform linear fitting.
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(6, dtype=float)
y = 3*x + 2
x += np.random.randn(6)/10
y += np.random.randn(6)/10
xm = x.mean()
ym = y.mean()
C = np.cov([x-xm,y-ym])
evals,evecs = np.linalg.eig(C)
a = evecs[1,evals.argmax()]/evecs[0,evals.argmax()]
b = ym-a*xm
xx=np.linspace(0,5,100)
yy=a*xx+b
plt.plot(x,y,'ro',xx,yy)
plt.show()
