参考文章: https://www.cnblogs.com/douzujun/p/8370657.html
https://blog.youkuaiyun.com/sxf1061926959/article/details/66976356?locationNum=9&fps=1
1、线性回归代码(使用矩阵运算求解系数)
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 15 22:02:02 2018
@author: xiaochenchen
"""
import numpy as np
import matplotlib.pyplot as plt
class LinearRegression():
def __init__(self):
self.W = None
def plotLine(self, w, b, xLow, xHigh):
x = np.arange(xLow, xHigh, 0.01)
y = w*x+b
plt.plot(x, y)
# x为变量矩阵, 每一行代表一条数据,
# x = [x1, x2, x3]
#
# = [x11,x21,x31
# x12,x22,x32]
# 其中xij表示第i个点的第j维坐标值
#
# X = [x1.T, 1
#