机器学习:最小二乘法(Python实现)

最小二乘法求回归

题目
机器学习:最小二乘法(Python实现)

    import numpy as np
    x_h = np.array([178,179,170,179,165,169,177,167,172,167])
    f_h = np.array([185,187,176,187,168,173,182,177,180,170])
    x_bar = np.average(x_h)
    f_bar = np.average(f_h)
    sum1 = np.dot(x_h,f_h.transpose())
    sum2 = np.dot(x_h,x_h.transpose())
    w = (sum1 - 10*x_bar*f_bar)/(sum2-10*x_bar*x_bar)
    b = f_bar - w * x_bar
    print(w,b)
上一篇:3月5日JindoFS系列直播【Hadoop Job committer 的演化和发展】


下一篇:【alive-progress】Python控制台输出动态进度条