Inverse machine learning framework for optimizing lightweight metamaterials