를 사용합니다.내가 다중 선형 회귀를 코드에 노력하고 있어요 NoneType
least = optimize.minimize(residsq(xmat, ylist, coeff), coeff, constraints = ({'type': 'eq', 'fun': sum(resid(xmat, ylist, coeff))}), method = 'BFGS') # Choose the coefficients that minimize the sum of the residuals squared subject to keeping the sum of the residuals equal to 0.
xmat이 벡터의 목록은 다음과 같습니다 : 내 프로그램에 오류가 발생합니다 경우 다음 코드 줄이야 [[3,5,2]을, [3,1,6], [7,2,3] , [9, -2,0]]. ylist는 xmat와 동일한 길이의 목록입니다 : [5,2,7,7]. COEFF는 계수리스트, 초기 [평균 (ylist), 0, 0, 0]이다 ([상수, b_0, B_1, B_2). 잔유는 각 포인트에 대한 잔차의 목록이며, residsq 잔차의 N2 규범 (제곱의 합 SQRT)이다.
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import linregtest
File "C:\Python33\lib\site-packages\linregtest.py", line 4, in <module>
out = linreg.multilinreg(xmat, ylist, True)
File "C:\Python33\lib\site-packages\linreg.py", line 120, in multilinreg
least = optimize.minimize(residsq(xmat, ylist, coeff), coeff, constraints = ({'type': 'eq', 'fun': sum(resid(xmat, ylist, coeff))}), method = 'BFGS') # Choose the coefficients that minimize the sum of the residuals squared subject to keeping the sum of the residuals equal to 0.
File "C:\Python33\lib\site-packages\scipy\optimize\_minimize.py", line 302, in minimize
RuntimeWarning)
File "C:\Python33\lib\idlelib\PyShell.py", line 60, in idle_showwarning
file.write(warnings.formatwarning(message, category, filename,
AttributeError: 'NoneType' object has no attribute 'write'
어디에서 파일을 가져 왔으며이 오류를 어떻게 억제합니까?
편집 : 하나의 문제를 해결, 서로를 찾을 수 있습니다. SciPy가 부유물을 부르는 곳을 결정하도록 도와 줄 수 있을까요?
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import linregtest
File "C:\Python33\lib\site-packages\linregtest.py", line 4, in <module>
out = linreg.multilinreg(xmat, ylist, True)
File "C:\Python33\lib\site-packages\linreg.py", line 123, in multilinreg
least = optimize.minimize(residsq(xmat, ylist, coeff), coeff, constraints = ({'type': 'eq', 'fun': sumresid(xmat, ylist, coeff)}), method = 'SLSQP') # Choose the coefficients that minimize the sum of the residuals squared subject to keeping the sum of the residuals equal to 0.
File "C:\Python33\lib\site-packages\scipy\optimize\_minimize.py", line 364, in minimize
constraints, **options)
File "C:\Python33\lib\site-packages\scipy\optimize\slsqp.py", line 301, in _minimize_slsqp
meq = sum(map(len, [atleast_1d(c['fun'](x, *c['args'])) for c in cons['eq']]))
File "C:\Python33\lib\site-packages\scipy\optimize\slsqp.py", line 301, in <listcomp>
meq = sum(map(len, [atleast_1d(c['fun'](x, *c['args'])) for c in cons['eq']]))
TypeError: 'float' object is not callable
Numpy가 아닌 PyShell/gui 셸에 문제가있는 것 같습니다. NumPy와 경고를 표시하고, 어떤 이유로 PyShell이 존재하지 않는 파일 객체에 그 쓰기를 시도하는 것 같습니다. – cge
IDLE에서 python 3의 버그처럼 보입니다. 쉘에 인쇄해야하는 경고와 동일한 문제가 있습니다. – user333700