Prediction of uncompensated polarity in ultrathin films