This paper proposes a data-driven matching algorithm for the problem of ride pooling, which is a transportation mode enabling people to share a vehicle for a trip. The problem is considered as a variant of matching problem, since it aims to find a matching between drivers and riders. Proposed algorithm is a machine learning algorithm based on rank aggregation idea, where every feature in a multi-feature dataset provides a ranking of candidate drivers and weight for each feature is learned from past data through an optimization model. Once weight learning and candidate ranking problems are considered simultaneously, resulting optimization model becomes a nonlinear bilevel optimization model, which is reformulated as a single level mixed-integer nonlinear optimization model. To demonstrate the performance of the proposed algorithm, a real-life dataset from a mobile application of a ride pooling start-up company is used and company's current approach is considered as benchmark. Results reveal that proposed algorithm correctly predicts the first choice of riders 17% to 28% better compared to the benchmark in different scenarios. Similarly, proposed algorithm offers recommendation lists in which the preferred driver is ranked 0.38 to 1.12 person closer (to the rider's actual choice) compared to the benchmark.