计算多元线性回归

时间:2015-12-11 13:21:50

标签: python numpy linear-regression

我有这两组,Set A和Set B(https://paste.debian.net/343292/),其中包含多个先前执行的数据。集合B包含总执行时间,集合A包含执行时的几个变量。

我有这个代码来计算多元线性回归[1],但最后预测的时间是负值。我不知道我是否在python代码中,或在2组中,或在我计算新time的方式中有问题。我在哪里有这个问题?

[1] Python代码

xx = np.array(set_a)
yy = np.array(set_b)

A = np.column_stack((xx, np.ones(len(xx))))

# linearly generated sequence
coeffs = linalg.lstsq(A, yy)[0]  # obtaining the parameters

wqueueacapacity = coeffs[0]
wbytesread = coeffs[1]
wmaps = coeffs[2]
wcpu_info = coeffs[3]
wmem_info = coeffs[4]

# I predict the time by multiplying weights with new params that I don't depict here.
time = (wbytesread * params[1]) + (wqueueacapacity * params[0]) + (wmaps * params[2]) + (wcpu_info * params[3]) + (wmem_info * params[4]) + coeffs[5]

0 个答案:

没有答案