Machine learning reveals how black holes grow