修补管道.score()
和.fit()
方法导致 AutoMLSearch 测试中出现以下消息:
再现
结帐主
pytest -s evalml/tests/automl_tests/test_automl.py::test_automl_rerun
@bchen1116如果你在 score 模拟中添加return_value
它应该消失:
@patch('evalml.pipelines.BinaryClassificationPipeline.score', return_value={"Log Loss Binary": 0.2})
@freddyaboulton这是我们需要添加到所有.score()
模拟中的东西吗? 这会是这个错误的最佳解决方案吗?
我想我犹豫是否将其称为错误,因为它不会以这种方式改变 automl 的行为,从而导致测试在应该失败时通过,反之亦然。
潜在的问题是,如果您不提供 return_value,则会返回MagicMock
。 最后,我们使用 f 字符串记录分数:
logger.info(f"Best pipeline {self.objective.name}: {best_pipeline['score']:3f}")
它对 MagicMock 使用__format__
方法,我猜它没有定义。
也许如果我们改变调用日志记录的方式,我们可以避免丑陋的日志,但我担心这会使代码复杂化而没有什么好处。
你怎么看?
啊,我明白了,这是有道理的。 我不确定那个消息是从哪里来的。 我认为这种行为很好,因为它似乎不会对 AutoML 的行为有害。 感谢您的帮助,我会关闭它!