You should be using the field with to do the space padding instead of manually including spaces in your format string. This will make the code cleaner:
```
ftable.write("%s %16.3f %8.3f %7.3f\n" %
    (thresholds[k], avg_scores[0, k], avg_scores[1, k], avg_scores[2, k]))
```