这是我代码的一部分:
def ml_pipeline(self):
if self.control_panel['ml_pipeline_switch']:
self.model = make_pipeline(self.preprocessor, self.control_panel['ml_algo'][1])
self.model.fit(self.X_train, self.y_train)
def ml_pipeline_result(self, show_control_panel_switch=True):
if self.control_panel['ml_pipeline_switch']:
print('Model score (training set): %.3f' % self.model.score(self.X_train, self.y_train))
print('Model score (test set): %.3f' % self.model.score(self.X_test, self.y_test))
score()
似乎正在产生准确性。如何将准确性与其他性能指标(如F1-macro
或recall-macro
(交换?我在文档中找不到任何内容。
对你的问题的简短回答是否定的,除非你破解并重新定义/覆盖scikit-learn
函数。
使用pipe.score()
时,它会从管道末尾的分类器调用 score 方法。
现在,幕后发生的事情是,scikit-learn
中的所有分类器都基于ClassifierMixin
类,为此.score()
是通过accuracy_score
定义的,这是硬编码的(见这里(。