Prototype optimization for nearest-neighbor classification