onehot 编码

 from sklearn.preprocessing import LabelEncoder

#Auto encodes any dataframe column of type category or object.

def dummyEncode(df):

        columnsToEncode = list(df.select_dtypes(include=['category','object']))

        le = LabelEncoder()

        for feature in columnsToEncode:

            try:

                df[feature] = le.fit_transform(df[feature])

            except:

                print('Error encoding '+feature)

        return df

    

X=dummyEncode(X)

评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理