Learning Weakly Convex Sets in Metric Spaces