我正在致力于将LogisticRegression文本分类从单词特征升级到双词特征(双词特征)。然而,当我在发送到patsy.dmatrices的公式中包含两个单词的特征时,我收到以下错误...
y, X = dmatrices("is_host ~ dedicated + hosting + dedicated hosting", df, return_type="dataframe")
File "<string>", line 1
dedicated hosting
^
SyntaxError: unexpected EOF while parsing
我在网上四处寻找如何实现这一点的例子,但没有找到任何东西。我尝试在公式中使用一些不同的语法选项,但似乎都不起作用。
"is_host ~ dedicated + hosting + {dedicated hosting}"
"is_host ~ dedicated + hosting + (dedicated hosting)"
"is_host ~ dedicated + hosting + [dedicated hosting]"
在传递给dmatricies的公式中包含多个单词功能的正确方法是什么?
发布于 2016-04-11 10:56:39
您需要:
y, X = dmatrices("is_host ~ dedicated + hosting + Q('dedicated hosting')", df, return_type="dataframe")
https://stackoverflow.com/questions/30548673
复制相似问题