Depends where. Try sneaking up on pirates in the middle of the ocean. Not to mention that ninjas tend to not work as a group. But 1 on 1 in a controlled environment (without the pirate having guns and the ninja having to advance a large distance in full view) ninjas would most likely win as they were a select, highly trained group of assassins, while most of the pirates were opportunists, people trying to get rich over the backs of others while not having any particular skills themselves (so similar to modern day bankers).