Van*_*eng 6 python numpy statsmodels
我想知道是哪条线或方法引起了未来警告!
predictors = weekly.columns[1:7] # the lags and volume
X = sm.add_constant(weekly[predictors]) # sm: statsmodels
y = np.array([1 if el=='Up' else 0 for el in weekly.Direction.values])
logit = sm.Logit(y,X)
results=logit.fit()
print(results.summary())
Run Code Online (Sandbox Code Playgroud)
C:\ Anaconda3 \ lib \ site-packages \ numpy \ core \ fromnumeric.py:2389:FutureWarning:方法.ptp已过时,将在以后的版本中删除。请改用numpy.ptp。返回ptp(axis = axis,out = out,** kwargs)
weekly[predictors]将返回weekly[[predictors]]DataFrame的系列表示。既然警告告诉要使用numpy.ptp,那么通过添加属性valuestoweekly[predictors]将使警告消失,即
X = sm.add_constant(weekly[predictors].values)
Run Code Online (Sandbox Code Playgroud)
或者您可以使用以下方法to_numpy():
X = sm.add_constant(weekly[predictors].to_numpy())
Run Code Online (Sandbox Code Playgroud)
它将weekly[predictors]系列转换为 NumPy 数组。
生成此警告的行是这样的:
X = sm.add_constant(weekly[predictors]) # sm: statsmodels
Run Code Online (Sandbox Code Playgroud)
不幸的是我有同样的问题。
| 归档时间: |
|
| 查看次数: |
2598 次 |
| 最近记录: |