我在python中使用redisbayes library来实现朴素贝叶斯分类。但是,当我写 -在python中建立redis连接
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中做朴素贝叶斯分类?
'r = redis.StrictRedis(host = YOUR_HOST,port = 6379,db = YOUR_DB)'一直对我很好。你只需要'import redis' – fedorqui