在Ubuntu 14.04中,我已经安装了基于https://dato.com/download/install-graphlab-create-command-line.html的Graphlab,它似乎工作正常。
但是,我在尝试使用推荐器模块时收到此错误:
import graphlab
from graphlab.recommender import ranking_factorization_recommender
在第一行中,导入graphlab时没有任何错误。但是,第二行会导致此错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-34df81ffb957> in <module>()
----> 1 from graphlab.recommender import ranking_factorization_recommender
ImportError: No module named recommender
如何解决问题?感谢
答案 0 :(得分:1)
这只是命名空间问题。 recommender
实际上存在于`toolkits模块中,所以这应该有效:
import graphlab
from graphlab.toolkits.recommender import ranking_factorization_recommender
答案 1 :(得分:0)
Graphlab已经在__init__.py
文件中为您导入了所有内容。
只是做:
from graphlab import ranking_factorization_recommender
from graphlab import <any_other_recommender>
以下是graphlab.__init__.py
文件的摘录:
from graphlab.util import get_runtime_config
from graphlab.util import set_runtime_config
import graphlab.connect as _mt
import graphlab.connect.aws as aws
from . import visualization
import os as _os
import sys as _sys
if _sys.platform != 'win32' or \
(_os.path.exists(_os.path.join(_os.path.dirname(__file__), 'cython', 'libstdc++-6.dll')) and \
_os.path.exists(_os.path.join(_os.path.dirname(__file__), 'cython', 'libgcc_s_seh-1.dll'))):
from graphlab.data_structures.sgraph import Vertex, Edge
from graphlab.data_structures.sgraph import SGraph
from graphlab.data_structures.sarray import SArray
from graphlab.data_structures.sframe import SFrame
from graphlab.data_structures.sketch import Sketch
from graphlab.data_structures.image import Image
from graphlab.data_structures.sgraph import load_sgraph, load_graph
from graphlab.toolkits._model import Model, CustomModel
import graphlab.aggregate
import graphlab.toolkits
import graphlab.toolkits.clustering as clustering
import graphlab.toolkits.distances as distances
...