This paper proposes an ensemble learning based approach for convexifying AC power flow equations, which differs from the existing relaxation-based convexification techniques. The proposed approach is based on the quadratic power flow equations in rectangular coordinates. To develop this data-driven convex model of power flow, the polynomial regression (PR) is first deployed as a basic learner to fit convex relationships between the independent and dependent variables. Then, ensemble learning algorithms, i.e. gradient boosting (GB) and bagging, are introduced to combine learners to boost model performance. Based on the learned convex models of power flow, optimal power flow (OPF) is formulated as a convex quadratic programming problem. The simulation results on IEEE standard cases illustrate that, 1) GB outperforms PR and bagging on the prediction accuracy, 2) in context of solving OPF, the proposed data-driven convex model outperforms the conventional SDP relaxation in both accuracy and computational efficiency.