У меня есть python Dict, когда я использую min()
. Смотрите мой код
scores = {leaf_size: round(get_mae(leaf_size, train_X, val_X, train_y, val_y)) for leaf_size in candidate_max_leaf_nodes}
best_tree_size = min(scores, key=scores.get)
get_mae () - это просто функция для расчета средней абсолютной ошибки.
, но она показывает следующую ошибку
TypeError Traceback (most recent call last)
<ipython-input-48-aa5b1fc6e492> in <module>
8 # print(dict)
9 scores = {leaf_size: round(get_mae(leaf_size, train_X, val_X, train_y, val_y)) for leaf_size in candidate_max_leaf_nodes}
---> 10 best_tree_size = min(scores, key=scores.get)
11 # list = scores.items()
TypeError: 'int' object is not callable