Supply chain members can intelligently learn their decisions based on historical data by using Machine-Learning (ML) algorithms. To coordinate the supply chain, the data-driven contract design problems for three contracts—buyback, quantity flexibility, and combined quantity flexibility and rebate—were investigated for a supply chain with one manufacturer and multiple retailers under algorithm sharing and algorithm competition. The problems were formulated as bi-level optimization models by introducing nonlinear mapping from historical demand data to ordering decisions and using ML algorithms to learn the mapping parameters. The bi-level optimization models were transformed into semi-infinite programming models and solved using the (nested) cutting plane methods. Empirical studies using data from two databases showed that algorithm sharing or algorithm competition, the type of contract used, and learning algorithms were the three factors influencing the performance of supply chain coordination when using a data-driven contract design. Algorithm sharing was found to be more beneficial to the supply chain members than algorithm competition in promoting supply chain coordination. An effective incentive mechanism, such as an individualized buyback ratio and a rebate from the manufacturer to the retailers with a good forecast performance, can encourage the retailers to participate in algorithm sharing and improvement.