- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在运行以下代码来创建并拟合 GaussianNB 分类器:
features_train, features_test, labels_train, labels_test = preprocess()
### compute the accuracy of your Naive Bayes classifier
# import the sklearn module for GaussianNB
from sklearn.naive_bayes import GaussianNB
import numpy as np
### create classifier
clf = GaussianNB()
### fit the classifier on the training features and labels
clf.fit(features_train, labels_train)
在本地运行上述内容:
>>> runfile('C:/.../naive_bayes')
no. of Chris training emails: 4406
no. of Sara training emails: 4383
>>> clf
GaussianNB()
我相信这会检查“preprocess()”,因为它成功加载了 features_train、features_test、labels_train、labels_test。
当我尝试 clf.score 或 clf.predict 时,出现 MemoryError:
>>> clf.predict(features_test)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\sklearn\naive_bayes.py", line 64, in predict
jll = self._joint_log_likelihood(X)
File "C:\Python27\lib\site-packages\sklearn\naive_bayes.py", line 343, in _joint_log_likelihood
n_ij -= 0.5 * np.sum(((X - self.theta_[i, :]) ** 2) /
MemoryError
>>> clf.score(features_test,labels_test)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\sklearn\base.py", line 295, in score
return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
File "C:\Python27\lib\site-packages\sklearn\naive_bayes.py", line 64, in predict
jll = self._joint_log_likelihood(X)
File "C:\Python27\lib\site-packages\sklearn\naive_bayes.py", line 343, in _joint_log_likelihood
n_ij -= 0.5 * np.sum(((X - self.theta_[i, :]) ** 2) /
MemoryError
我不认为这是我的内存问题,因为我在任务管理器上没有看到 RAM 峰值,也没有接近我机器上的内存使用量。
我怀疑这是Python版本和库版本的问题。
对于诊断此问题的任何帮助,我们表示赞赏。我可以根据需要提供更多信息。
最佳答案
我相信我在在线阅读一些相关帖子后回答了我的问题(没有使用之前回答的 Stackoverflow 帖子)。
对我来说,关键是通过 Anaconda 迁移到 64 位 Python。当在 32 位 Python 中运行的完全相同的代码在 64 位中重试时,所有“MemoryError”问题都得到了解决。据我所知,这是唯一改变的变量。
也许这不是一个非常令人满意的答案,但如果这个问题可以保留给其他人在将来搜索完全相同的 sklearn MemoryError 问题,那就太好了。
关于Python sklearn GaussianNB : "MemoryError" but no leads on how to fix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35346581/
在 Dynamics CRM 中,潜在客户实体同时具有状态和状态原因。使用 API 我可以获得所有状态原因。我被绊倒的地方是当我的用户选择状态原因时我想倒退并找出哪个状态与所选状态原因相关联。 以下是
我已经搜索了几个小时,但仍然找不到正确的答案。这可能看起来很简单,但我需要你的帮助,这是问题:有两个按钮,1.) 递增按钮和 2.) 递减(减)按钮,当我单击按钮 1 时,值 $a 得到 +1 当我单
我有一个带有3个kafka节点和3个zk节点的kakfa集群。 生产者在AWS机器上尝试将数据推送到我的Intranet服务器上运行的kafka集群上。 使用以下命令从控制台创建主题(JOB_AWS_
我知道之前已经有人问过如何用前导空格分割字符串的问题,例如: String str = " I want to be split \t!" String[] sarr = str.split("\\
我正在尝试使用 xlsx 将 Excel 2010 工作簿文件中的工作表读入 R和 XLConnect包。尽管将工作表中的单元格格式化为“文本”,但两者都在邮政编码列上删除了前导零。 wb <- lo
在 AudioUnit 插件中,我使用 NSFont。 NSFontManager* fontManager = [NSFontManager sharedFontManager]; NSFont*
我有一个简单的触发器,可以在创建或更新潜在客户时从潜在客户对象中提取数据并将其放入自定义“财务”对象中。由于某种原因,Trigger.new[i].Id 在插入之前触发的触发器中返回 NULL。 我快
当 lead() 值不在当前行的范围内时,我在查询时遇到问题,范围边缘的行返回 null lead() 值。 假设我有一个简单的表来跟踪连续的计数器 create table anytable ( w
考虑一下, 浅蓝色 strip 的宽度(比方说)为 10。 红色 block 通过leading measure链接到浅蓝色 strip 。 假设该约束的常量为零。当然,红色 block 的 x 位置
如何从后续版本号字符串中删除“前导”零? 5.002.008.80911 --> 5.2.8.80911 谢谢。 最佳答案 使用 str.split 和 str.join 例如: s = "5.002
我正在尝试查询 View ,但收到“ORA-01873:间隔的前导精度太小”错误消息。下面是查询。 Select * from table order by Col1. 下面是 View 结构: Co
突然(但不幸的是,我不知道“突然”是什么时候;我知道它在过去的某个时候运行良好)我的一个查询开始需要 7 秒以上而不是毫秒来执行。我有 1 个本地表和 3 个通过数据库链接访问的表。 3 个远程表连接
假设我的表结构是这样的 我计划按(USER 和 SEQUENCE)对其进行分组并获取下一个序列的 LEAD 时间戳。这是我正在寻找的输出 如果可能的话,我可以在不使用 LEAD 函数的 JOIN 的情
当我在 ConstrainedBox 中放置 ListTile 的前导时,我遇到了图像大小问题,图像太小,无法填充到更大的尺寸,有什么想法可以使此图像大小可以跟随 Card 的高度吗? 谢谢你。 Li
我有一个 Spring MVC Web 应用程序,应该提供静态资源。因此我有以下 Spring 配置: 但是对资源的每个请求都会导致同样丑陋的 ClassCastException: java.la
void X() { lock(&m); while(x || y) wait( &farpar, &m); x ++; unlock(&m); // Do X stuff loc
我不知道该怎么做。我的数据结构如下: DATE: Amount ID 3/5/2018 0
表和架构设置 考虑下表和触发器, CREATE TABLE t1 ( c1 int, c2 text, c3 text, m1 int, m2 int, primary key
有什么方法可以强制 PostgreSQL LAG() 和 LEAD() 函数使用的值不是来自前导行,而是同一分区的下一个等级? ------------------------------------
我正在使用 Python 的 argparse解析命令行参数的模块。考虑以下简化示例, # File test.py import argparse parser = argparse.Argumen
我是一名优秀的程序员,十分优秀!