如何减少 Scikit-Learn Vectorizers 的内存使用量? [英] How can i reduce memory usage of Scikit-Learn Vectorizers?

查看:21
本文介绍了如何减少 Scikit-Learn Vectorizers 的内存使用量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TFIDFVectorizer 占用太多内存,矢量化 470 MB 的 100k 文档需要超过 6 GB,如果我们处理 2100 万个文档,它将无法容纳我们拥有的 60 GB RAM.

TFIDFVectorizer takes so much memory ,vectorizing 470 MB of 100k documents takes over 6 GB , if we go 21 million documents it will not fit 60 GB of RAM we have.

所以我们选择 HashingVectorizer 但仍然需要知道如何分发哈希向量化器.Fit 和 partial fit 没有任何作用,那么如何使用 Huge Corpus?

So we go for HashingVectorizer but still need to know how to distribute the hashing vectorizer.Fit and partial fit does nothing so how to work with Huge Corpus?

推荐答案

我强烈建议您使用 HashingVectorizer 在大型数据集上拟合模型.

I would strongly recommend you to use the HashingVectorizer when fitting models on large dataset.

HashingVectorizer 与数据无关,只有来自 vectorizer.get_params() 的参数是重要的.因此 (un)pickling `HashingVectorizer 实例应该非常快.

The HashingVectorizer is data independent, only the parameters from vectorizer.get_params() are important. Hence (un)pickling `HashingVectorizer instance should be very fast.

基于词汇的向量化器更适合对小数据集进行探索性分析.

The vocabulary based vectorizers are better suited for exploratory analysis on small datasets.

这篇关于如何减少 Scikit-Learn Vectorizers 的内存使用量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆