1
Logistic迴歸模型使用statesmodels:Statsmodels:書寫式的短方式
log_reg = st.logit(formula = 'label ~ pregnant + glucose + bp + insulin + bmi + pedigree + age', data=pima).fit()
是存在寫入式(懷孕+葡萄糖+ BP +胰島素+ BMI +譜系+年齡)的第二部分中的任何短方法?這裏所有的列都必須明確提及。如果列數超過100列,則編寫起來會很困難,而且這個陳述也會很長。
感謝您的意見。使用Pandas dataframe列名找到一種方法: – BhushanD
'str1 = pima.columns [-1] +「〜」+「+」.join(list(pima.columns [1:len(pima.columns)-1])' 'log_reg = st.logit(公式= str1,data = pima).fit()' – BhushanD