RandomForestClassifier.fit 在不同机器上使用的内存量不同

由于某些原因,来自sklearn.ensembleRandomForestClassifier.fit在我的本地机器上只使用了2.5GB的内存,但在我的服务器上使用了几乎7GB的内存,训练集完全相同。

不包括导入的代码大致如下:

y_train = data_train['train_column']x_train = data_train.drop('train_column', axis=1)# 内存消耗差异从这里开始clf = RandomForestClassifier(n_estimators=100, random_state=42)clf = clf.fit(x_train, y_train)preds = clf.predict(data_test)

我的本地机器是配备16GB内存和4核CPU的MacBook Pro,我的服务器是DigitalOcean云上的Ubuntu服务器,同样配备8GB内存和4核CPU。

scikit-learn的版本是0.18,Python的版本是3.5.2

我甚至无法想象可能的原因,任何帮助都会非常有用。

更新

内存错误出现在fit方法内的以下代码中:

# 并行循环:我们使用线程后端,因为Cython代码# 用于拟合树木内部释放了Python的GIL,# 在这种情况下,线程总是比多处理更有效。trees = Parallel(n_jobs=self.n_jobs, verbose=self.verbose,                 backend="threading")(    delayed(_parallel_build_trees)(        t, self, X, y, sample_weight, i, len(trees),        verbose=self.verbose, class_weight=self.class_weight)    for i, t in enumerate(trees))

更新2

关于我的系统的信息:

# 本地Darwin-16.1.0-x86_64-i386-64bitPython 3.5.2 (default, Oct 11 2016, 05:05:28)[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)]NumPy 1.11.2SciPy 0.18.1Scikit-Learn 0.18# 服务器Linux-3.13.0-57-generic-x86_64-with-Ubuntu-16.04-xenialPython 3.5.1 (default, Dec 18 2015, 00:00:00)[GCC 4.8.4]NumPy 1.11.2SciPy 0.18.1Scikit-Learn 0.18

还有我的NumPy配置:

# 服务器>>> np.__config__.show()blas_opt_info:    libraries = ['openblas', 'openblas']    define_macros = [('HAVE_CBLAS', None)]    library_dirs = ['/usr/local/lib']    language = copenblas_info:    libraries = ['openblas', 'openblas']    define_macros = [('HAVE_CBLAS', None)]    library_dirs = ['/usr/local/lib']    language = clapack_opt_info:    libraries = ['openblas', 'openblas']    define_macros = [('HAVE_CBLAS', None)]    library_dirs = ['/usr/local/lib']    language = cblas_mkl_info:  NOT AVAILABLEopenblas_lapack_info:    libraries = ['openblas', 'openblas']    define_macros = [('HAVE_CBLAS', None)]    library_dirs = ['/usr/local/lib']    language = c# 本地>>> np.__config__.show()blas_opt_info:    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']    define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]    extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']blas_mkl_info:  NOT AVAILABLEatlas_threads_info:  NOT AVAILABLElapack_mkl_info:  NOT AVAILABLEopenblas_lapack_info:  NOT AVAILABLEatlas_info:  NOT AVAILABLEatlas_3_10_blas_info:  NOT AVAILABLElapack_opt_info:    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']    define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]    extra_compile_args = ['-msse3']openblas_info:  NOT AVAILABLEatlas_3_10_blas_threads_info:  NOT AVAILABLEatlas_3_10_threads_info:  NOT AVAILABLEatlas_3_10_info:  NOT AVAILABLEatlas_blas_threads_info:  NOT AVAILABLEatlas_blas_info:  NOT AVAILABLE

clf对象在两台机器上的表示是相同的:

RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',            max_depth=None, max_features='auto', max_leaf_nodes=None,            min_impurity_split=1e-07, min_samples_leaf=1,            min_samples_split=2, min_weight_fraction_leaf=0.0,            n_estimators=100, n_jobs=1, oob_score=False, random_state=42,            verbose=0, warm_start=False)

回答:

好吧,在我将内核从3.13.0-57更新到4.4.0-28后,问题神奇地消失了。现在它消耗的内存甚至比我的本地Mac笔记本电脑还要少。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注