Understanding Nagelkerke R² (Pseudo R²)

Explained with an example in Python