Is pd.get_dummies one-hot encoding?

前端 未结 2 1760
一整个雨季
一整个雨季 2021-02-01 09:10

Given the difference between one-hot encoding and dummy coding, is the pandas.get_dummies method one-hot encoding when using default parameters (i.e. drop_fir

2条回答
  •  生来不讨喜
    2021-02-01 09:39

    First question: yes, pd.get_dummies() is one-hot encoding in its default state; see example below, from pd.get_dummies docs:

    s = pd.Series(list('abca'))
    pd.get_dummies(s, drop_first=False)
    

    Second question: [edited now that OP includes code example] yes, if you are one-hot encoding the inputs to a logistic regression model, it is appropriate to skip the intercept.

提交回复
热议问题