python - 在python中建立redis连接

标签 python redis bayesian

我正在使用 redisbayes library在 python 中实现朴素贝叶斯分类。但是当我写的时候——

rb = redisbayes.RedisBayes(redis=redis.Redis())
rb.train('good', 'sunshine drugs love sex lobster sloth')

它给出了以下错误 -

ConnectionError: Error 10061 connecting localhost:6379. 
No connection could be made because the target machine actively refused it.

我试过这样做-

pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
rb = redisbayes.RedisBayes(redis=redis.Redis(connection_pool=pool))

但它给出了同样的错误。我无法找到解决方案。我如何使用 python 建立与 redis 的连接,或者如何使用来自 MySQL 的训练数据在 python 中进行朴素贝叶斯分类?

最佳答案

你确实意识到你需要有一个本地运行的 Redis 服务器才能连接到它,看看你的进程列表中是否有 redis-server 如果它不存在而你也没有有一个注册服务,您可能需要安装它。查看 redis homepage 上的安装说明

关于python - 在python中建立redis连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19678365/

相关文章:

python - 访问字段 : different value if its stored in a dict

python - 计算文本文件中每个汉字的出现次数

python - 迁移到 GAE

python - 如何使用 Celery 和 Flask 实现缓存系统

caching - Azure Redis 缓存超时和无连接错误

python - 使用 pymc 解释 MCMC 运行的后验分布

Hadoop:在 Apache Mahout 中实现贝叶斯算法时出错

python - 如何更改conda base的路径

php - 如何获取带有偏移量和限制的predis数据?

correlation - 使用 PyMC 的贝叶斯相关性