scikit-learnのversionは0.21.3。
accuracy_scoreを直接使う時とget_scorer('accuracy')では引数が異なる。
https://github.com/scikit-learn/scikit-learn/blob/95d4f0841/sklearn/metrics/_scorer.py#L393-L398
$ python
Python 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 23:51:54)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn.metrics import get_scorer, accuracy_score
>>> from sklearn.linear_model import LogisticRegression
>>> accuracy_score([1, 2, 3], [4, 5, 3])
0.3333333333333333
>>> get_scorer('accuracy')([1, 2, 3], [4, 5, 3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __call__() missing 1 required positional argument: 'y_true'
>>> estimator = LogisticRegression().fit([[10], [12], [13]], [1, 2, 3])
/home/hidetomo/.pyenv/versions/miniconda3-4.3.30/lib/python3.6/site-packages/sklearn/linear_model/logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.
FutureWarning)
/home/hidetomo/.pyenv/versions/miniconda3-4.3.30/lib/python3.6/site-packages/sklearn/linear_model/logistic.py:469: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.
"this warning.", FutureWarning)
>>> estimator.predict([[10], [11], [12]])
array([3, 3, 3])
>>> get_scorer('accuracy')(estimator, [[10], [12], [13]], [1, 2, 3])
0.3333333333333333