An algorithm can be either initialized using the object or directly by constructing an convenience. Both has their pro and cons.
Directly initializing the object keeps the code clean and if you use an idea lets you quickly jump to the definition of the algorithm and find hyperparameters to modify.
from pymoo.algorithms.moo.nsga2 import NSGA2 algorithm = NSGA2()
An initialization through the convenience function does not need to add any new import, and it can be helpful if multiple algorithms shall be run on the same problem. This requires only changing the corresponding string. However, this only works if the objects share the same parameters or do not need additional ones.
from pymoo.factory import get_algorithm algorithm = get_algorithm("nsga2")