38Pull a random sample, and a stratified sample, for an ML training set in SQL.▼mediumMetaAmazonDatabricks1 replies◆ premiumBuilding a training set from a billion-row table means sampling, and the naive 'ORDER BY random() LIMIT n' sorts the whole table. Stratified sampling needs more care still. Here are both, done efficiently.Open full answer →
39Generate ML labels in SQL: did each user churn (no activity in the next 30 days)?▼hardNetflixSpotifyAmazon1 replies◆ premiumDefining the label is half the modeling problem, and the SQL hides two leakage traps: looking into the future for features, and a label window that isn't fully observed yet. Here is the correct query.Open full answer →