简体   繁体   English

我如何保存需要更少 memory 的机器学习 model

[英]How can i save a machine learning model that takes less memory

I am training a RandomForest Classifier with somewhat large dataset of around 580mb and it is taking more than 30 min to fit.我正在训练一个 RandomForest 分类器,它的数据集有些大,大约 580mb,需要 30 多分钟才能适应。 Now when I try to save the model using joblib then the saved model takes around 11.1gb of space.现在,当我尝试使用 joblib 保存 model 时,保存的 model 需要大约 11.1gb 的空间。 Is it normal or I can save the model more efficiently in terms of space consumed as I am thinking of deploying the model.这是正常的,还是我可以更有效地节省 model 在我正在考虑部署 model 时占用的空间。

Is it worth using a model that takes so much space because I have a decision tree model on same data that takes 278mb space and it's accuracy is just 2% lower(91%)是否值得使用占用如此多空间的 model,因为我有一个决策树 model 在相同的数据上占用 278mb 空间,它的准确性仅低 2%(91%)

my notebook 我的笔记本

This is model saving code这是 model 保存代码

from sklearn.externals import joblib  
# Save the model as a pickle in a file 
joblib.dump(Random_classifier, '/content/drive/My Drive/Random_classifier.pkl') 

I am a newbie so don't vote to close the question just leave a comment.我是新手,所以不要投票结束问题,只需发表评论即可。 I am willing to edit the question asap.我愿意尽快编辑问题。

Random Forest classification method is way expensive in memory.随机森林分类方法在 memory 中非常昂贵。 try to lower your decision trees number, might reduce some memory.尝试降低您的决策树数量,可能会减少一些 memory。 It seems your dataset is also very big so I think it seems legit your weights size.看来您的数据集也很大,所以我认为您的权重大小似乎是合法的。 Also I know there is pickle way to save weights, I would recommend to check it out too.我也知道有泡菜的方法可以减轻重量,我也建议您检查一下。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何稳定机器学习 model? - How can I stabilize a machine learning model? 如何将此代码中的数据保存在单独的文件中以创建机器学习 model? - How can I save data from this code in separate files to create a machine learning model? 如何在单次训练期间保存和快照机器学习模型? - How to save and snapshot machine learning model during a single training? 我可以告诉机器学习模型因变量是正态分布的吗? - Can I tell a machine learning model that the dependent variable is normally distributed? 我可以使用机器学习模型作为优化问题的目标函数吗? - Can I use a machine learning model as the objective function in an optimization problem? 如何提高线性回归模型的准确性?(使用python进行机器学习) - How can I increase the accuracy of my Linear Regression model?(machine learning with python) 如何在 Azure ML 服务中注册本地训练的机器学习模型? - How can I register in Azure ML Service a machine learning model trained locally? 如何在使用 Keras 的机器学习中使用单个 class 教授 model? - How can I teach a model using single class in machine learning using Keras? 我如何在机器学习中使用不同的数据集测试我的 model - how can i test my model using different dataset in machine learning 如何将一系列 numpy ndarrays 作为输入数据来训练 tensorflow 机器学习模型? - How can I have a series of numpy ndarrays as the input data to train a tensorflow machine learning model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM