AttributeError: 'function' object has no attribute 'summary'
AttributeError: 'function' object has no attribute 'summary'
我是 运行 线性回归,我得到 'summary' 的 attributeError。
我正在研究 windows OS, python 3.7
y=dataset
X=dataset [['A'] + ['B'] + ['C'] + ['D'] + ['E']]
X1 = sm.add_constant(X)
model = sm.OLS(endog = y, exog = X)
results = model.fit
results.summary()
AttributeError: 'function' object has no attribute 'summary'
来自 statsmodels
OLS example:
import numpy as np
import statsmodels.api as sm
# Artificial data:
nsample = 100
x = np.linspace(0, 10, 100)
X = np.column_stack((x, x**2))
beta = np.array([1, 0.1, 10])
e = np.random.normal(size=nsample)
# Our model needs an intercept so we add a column of 1s:
X = sm.add_constant(X)
y = np.dot(X, beta) + e
# Fit and summary:
model = sm.OLS(y, X)
results = model.fit()
print(results.summary())
print('Parameters: ', results.params)
print('R2: ', results.rsquared)
在你的情况下,results = model.fit
必须是 results = model.fit()
。
我是 运行 线性回归,我得到 'summary' 的 attributeError。
我正在研究 windows OS, python 3.7
y=dataset
X=dataset [['A'] + ['B'] + ['C'] + ['D'] + ['E']]
X1 = sm.add_constant(X)
model = sm.OLS(endog = y, exog = X)
results = model.fit
results.summary()
AttributeError: 'function' object has no attribute 'summary'
来自 statsmodels
OLS example:
import numpy as np
import statsmodels.api as sm
# Artificial data:
nsample = 100
x = np.linspace(0, 10, 100)
X = np.column_stack((x, x**2))
beta = np.array([1, 0.1, 10])
e = np.random.normal(size=nsample)
# Our model needs an intercept so we add a column of 1s:
X = sm.add_constant(X)
y = np.dot(X, beta) + e
# Fit and summary:
model = sm.OLS(y, X)
results = model.fit()
print(results.summary())
print('Parameters: ', results.params)
print('R2: ', results.rsquared)
在你的情况下,results = model.fit
必须是 results = model.fit()
。