In many cases, they aren't even comparable, because to get the most out of a class 2 item, you need a small ship; such ships can't use class 4 stuff.
I think it's better to compare the other numbers (mass, power use, damage, etc) of the new thing with the old thing (by pressing the COMPARE button). Blue numbers are positive effects, and red numbers are negative effects. For example, a power unit may provide 2 MW more power, but be 5 tons heavier (reducing jump range). It's up to you if you think it's worth it
Some units improve performance with the same mass, but others give the same performance with lower mass; chosing lower mass and similar performance improves jump range.