如何解决此基线减法代码中的EOF错误

时间:2019-06-27 16:53:51

标签: python-3.x pandas scipy eof baseline

我正在使用此代码从原始数据帧中形成基线数据帧。我的循环中不断出现EOF错误。

我搜寻了其他论坛来查看人们是否有类似的错误,但是他们的错误都有一些明显的语法错误。我的代码看起来非常完美,没有空格或语法错误,并且可以在其他论坛中为其他人工作。我可以根据需要链接论坛

def baseline_als(y,lam,p,niter=10):
    L = len(y) 
    D = sparse.diags([1,-2,1],[0,-1,-2], shape=(L,L-2)) 
    w = np.ones(L)
    for i in range(niter):
        W = sparse.spdiags(w, 0, L, L)
        Z = W + lam * D.dot(D.transpose())
        z = spsolve(Z, w*y)
        w = p * (y > z) + (1-p) * (y < z)
    return z

这是我得到的一些错误:

def baseline_als(y,lam,p,niter=10):
  File "<ipython-input-118-52ca3f75a662>", line 1
    def baseline_als(y,lam,p,niter=10):
                                   ^
SyntaxError: unexpected EOF while parsing

for i in range(niter):
  File "<ipython-input-124-a373ece7bc7f>", line 1
    for i in range(niter):
                      ^
SyntaxError: unexpected EOF while parsing

0 个答案:

没有答案
相关问题