Leveraging Machine learning for Sustainable and Self-sufficient Energy Communities