They'd have to be pretty dim pirates not to recognise it as an electric fence and a few bits of wire is all they'd need to overcome it. Might keep sea-cows and sea-horses away, I suppose?
In some jurisdictions you might end up in deep poo if anyone was harmed as a consequence of the kit - e.g. 'pirate' falls into the water and drowns/harms himself. In the UK you would certainly be at risk of that (not that you'd want to use it in the UK, maybe, but could be that other countries have similar laws?
If you carefully research the actions of armed pirates from around the world, they are desperate men who have no real intent on doing you harm. The just want what you have so they can sell and obtain a little money.
On virtually every occasion over the past 40 years, where force has been used to resist or challenge the pirates, the hapless crew who are being robbed, have either been killed or very seriously injured.
It seems to me to not resist and try and live through the event. If you see pirates approaching, have some sort of plan. DO NOT RESIST.
Try to do something like placing all your valuables in a very large Peli-case (or two) and then attaching to the anchor and lowering it over the side for about 2 fathoms until the threat is gone. Passports, money, ID, hand held GPS, Charts, camera etc.
Leave sacrificial equipment for the pirates. A few months ago on ybw, someone (stingo??) jokingly said get hold of some Zimbabwe currency. This is a very good idea as it is technically worthless but looks like a serious load of money!
Body posture such as keeping your head slightly bowed talking quietly and faultingly and try to hold your hands as in a supplicants manner. This will always ease a tricky situation which you hopefully will live through.
Peli-cases are not cheap but they are immersible waterproof to depth.