0

在 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

如何解决问题?谢谢

4

2 回答 2

1

这只是一个命名空间问题。recommender实际上存在于 `toolkits 模块中,所以这应该可以工作:

import graphlab
from graphlab.toolkits.recommender import ranking_factorization_recommender
于 2016-02-26T18:10:45.623 回答
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
...
于 2017-07-27T05:45:37.530 回答