Python 逻辑回归二元文本分类w/Patsy

Python 逻辑回归二元文本分类w/Patsy,python,machine-learning,scikit-learn,logistic-regression,patsy,Python,Machine Learning,Scikit Learn,Logistic Regression,Patsy,我正在将LogisticRecession文本分类从单词功能升级为双词功能。但是,当我在发送到patsy.dmatrices的公式中包含两个单词的功能时,我收到以下错误 y, X = dmatrices("is_host ~ dedicated + hosting + dedicated hosting", df, return_type="dataframe") File "<string>", line 1 dedicated hosting

我正在将LogisticRecession文本分类从单词功能升级为双词功能。但是,当我在发送到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
在传递给Dmatrices的公式中包含多词功能的正确方法是什么?

您想要:

y, X = dmatrices("is_host ~ dedicated + hosting + Q('dedicated hosting')", df, return_type="dataframe")

y, X = dmatrices("is_host ~ dedicated + hosting + Q('dedicated hosting')", df, return_type="dataframe")