gpt4 book ai didi

python - 机器学习: best technique to deal with a lot of categorical data

转载 作者:行者123 更新时间:2023-11-30 09:25:09 25 4
gpt4 key购买 nike

假设我有一个 5000 行、10 列的矩阵,其中大部分填充有分类数据(字符串),每列中有 10-30 个不同的字符串。在 python 中处理它的最佳理想方法/算法是什么? OneHotEncoder 会给我一个非常大的矩阵

最佳答案

Scikit-learn 的 one-hot 编码器默认使用稀疏矩阵,因此精确的矩阵形状不成问题(因为它不会存储非零条目)。

一些简单的 sklearn 算法(线性模型、树、朴素贝叶斯)能够处理此类稀疏数据 - 具体示例请参见 Computational Performance部分或 Classification of text documents using sparse features

关于python - 机器学习: best technique to deal with a lot of categorical data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46152154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com