首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AttributeError: NoneType对象没有属性“learn_predicates”

AttributeError: NoneType对象没有属性“learn_predicates”
EN

Stack Overflow用户
提问于 2018-05-10 05:32:01
回答 1查看 744关注 0票数 2

我有关于在表learning中找到的双打的信息,其中entity_id对双打是相同的。我想以身作则教Dedupe,但要犯错误。我做错了什么?

代码语言:javascript
复制
con = psycopg2.connect(database=db_conf['NAME'],
                   user=db_conf['USER'],
                   password=db_conf['PASSWORD'],
                   host=db_conf['HOST'],
                   cursor_factory=psycopg2.extras.RealDictCursor)
con.set_client_encoding('UTF8')
c = con.cursor()
if os.path.exists(settings_file):
    print('reading from ', settings_file)
    with open(settings_file, 'rb') as sf:
        deduper = dedupe.StaticDedupe(sf, num_cores=4)
else:
     fields = [{'field': 'name', 'variable name': 'name',
               'type': 'String', 'has missing': True},

              {'field': 'address', 'type': 'Text',
               'variable name': 'address', 'has missing': True},

          {'type': 'Interaction',
           'interaction variables': ['name', 'address']}
          ]

    deduper = dedupe.Dedupe(fields, num_cores=8)

    LEARNING_QUERY = "SELECT entity_id, name, address FROM learning;"
    c.execute(LEARNING_QUERY) `

    temp_d = dict((i, row) for i, row in enumerate(c))
    deduper.markPairs(dedupe.trainingDataDedupe(temp_d, 'entity_id'))
    del temp_d   
    deduper.train()

错误:

代码语言:javascript
复制
/home/sontata/venv/bin/python /home/sontata/PycharmProjects/test/actual_object_learning.py
INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/Grammar.txt
INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/PatternGrammar.txt
starting active labeling...
/home/sontata/venv/lib/python3.6/site-packages/rlr/lr.py:39: UserWarning: The line-search routine reaches the maximum number of evaluations.
  case_weights, self.alpha))
Traceback (most recent call last):
  File "/home/sontata/PycharmProjects/test/actual_object_learning.py", line 110, in <module>
    deduper.train()
  File "/home/sontata/venv/lib/python3.6/site-packages/dedupe/api.py", line 678, in train
    self.predicates = self.active_learner.learn_predicates(
AttributeError: 'NoneType' object has no attribute 'learn_predicates'

Process finished with exit code 1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-16 09:52:48

Lol,我应该在deduper.sample(temp_d, 15000)之前添加deduper.markPairs

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50266111

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档