I am using an Ordered Dictionary which contains all the values (n_estimators and error rates from an OOB estimation, as shown here.
I want to get the values with the lowest error rates first in the dictionary.
For example, below you can see that 222 has the highest error rate.
OrderedDict([('RandomForest_AWA_Fp1, max_features=7',
[(220, 0.10833333333333328),
(221, 0.10833333333333328),
(222, 0.10952380952380958),
(223, 0.10833333333333328)])
])
I want to sort this dictionary in this order: 220, 221, 223, 222 (by value in descending order)
I have tried:
OrderedDict(sorted(error_rate.items(), key=lambda t: min(t[0])))
But I do not see any difference.
ERROR I GET:
File "<ipython-input-85-0592e683c6a9>", line 3
pp(dict(OrderedDict(sorted([(k, sorted(v, key=min)) for k, v in d.items()], key=lambda(k, v): min(v)))))
^
SyntaxError: invalid syntax