Questions tagged «one-hot-encoding»


20
如何在Python中进行热编码?
我有一个80%分类变量的机器学习分类问题。如果要使用一些分类器进行分类,是否必须使用一种热编码?我可以在没有编码的情况下将数据传递给分类器吗? 我正在尝试进行以下功能选择: 我读了火车文件: num_rows_to_read = 10000 train_small = pd.read_csv("../../dataset/train.csv", nrows=num_rows_to_read) 我将类别特征的类型更改为“类别”: non_categorial_features = ['orig_destination_distance', 'srch_adults_cnt', 'srch_children_cnt', 'srch_rm_cnt', 'cnt'] for categorical_feature in list(train_small.columns): if categorical_feature not in non_categorial_features: train_small[categorical_feature] = train_small[categorical_feature].astype('category') 我使用一种热编码: train_small_with_dummies = pd.get_dummies(train_small, sparse=True) 问题是,尽管我使用的是坚固的机器,但第3部分经常卡住。 因此,没有一种热编码,我就无法进行任何特征选择来确定特征的重要性。 您有什么推荐的吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.