【发布时间】:2017-09-19 15:21:12
【问题描述】:
我在 Python 中运行以下回归代码,但出现错误(PatsyError:模型缺少必需的结果变量)。我如何解决它? 谢谢
Y = spikers['grade']
X = spikers[['num_pageview', 'num_video_play_resume', 'eng_proficiency', 'english']]
model = smf.ols(Y,X).fit()
model.summary()
【问题讨论】:
-
您需要展示更多代码。像 patsy 字符串。
-
spikers['grade']可能是空值。只是一个猜测。提供更多信息以获得更多帮助。阅读,stackoverflow.com/help/mcve -
看起来你正在混合这两个接口,如果你在数组或 pandas Series/DataFrame 中直接有 y 和 x,请使用
sm.OLS(大写字母)。使用公式接口时,第一个参数为公式字符串smf.ols("grade ~ ...)
标签: python pandas regression