First one would be
((prediction - test['actual']) ** 2).sum()
Second one would be:
((prediction - test['actual'].mean()) ** 2).sum()