minor updates

@avulanov I made some minor updates:

1. change confusions to key by (label, prediction), which is more common
2. reuse `n`
3. organize imports