Jan 16, 2026 O2O Coupon-Use Prediction: A Tianchi Competition Project Report AI-translated 1.Project objectives and requirementsComplete the online evaluation for the O2O coupon-use prediction task on Tianchi.2.Development environment1.Operating system: Archlinux/NixOS.2.Basic hardware: AMD Ryzen™ 7 7840HS processor and 16 GB of memory.3.Python and package versions1:•Python 3.13 or later•Pandas 2.3.3 or later•xgboost 3.1.2 or later•chinesecalendar 1.11.0 or later•jupyter 1.1.1 or later•lightgbm 4.6.0 or later•pyarrow 22.0.0 or laterThe pyproject.toml file is as follows: [project]name = "my-o2o"version = "0.1.0"description = "code for aliyun tianchi o2o"readme = "README.md"requires-python = ">=3.13"dependencies = [ "chinesecalendar>=1.11.0", "jupyter>=1.1.1", "lightgbm>=4.6.0", "pandas>=2.3.3", "pyarrow>=22.0.0", "xgboost>=3.1.2",]3.Project workFrom 0.7206 to 0.8175Throughout December, I worked on dataset splitting, feature engineering, and model ensembling in parallel, improving test-set AUC from 0.7206 to 0.8175.I used Git for version control. The complete change history is available through git log, and the remote repository is https://github.com/TwinklerG/my_o2o.Dataset splittingDropping the middle segment and providing richer information in the history segment produced better results on the test set.# Training settrain_history_field = off_train[ off_train["date_received"].isin(pd.date_range("2016/1/16", periods=75))] # [2016/1/16,2016/3/31)1Based on pyproject.toml_ = off_train[ off_train["date"].isin(pd.date_range("2016/3/16", periods=15))] # [2016/3/16,2016/3/31)train_label_field = off_train[ off_train["date_received"].isin(pd.date_range("2016/3/31", periods=31))] # [2016/3/31,2016/5/1)# Validation setvalidate_history_field = off_train[ off_train["date_received"].isin(pd.date_range("2016/3/2", periods=75))] # [2016/3/2,2016/5/16)_ = off_train[ off_train["date"].isin(pd.date_range("2016/5/1", periods=15))] # [2016/5/1,2016/5/16)validate_label_field = off_train[ off_train["date_received"].isin(pd.date_range("2016/5/16", periods=31))] # [2016/5/16,2016/6/16)# Test settest_history_field = off_train[ off_train["date_received"].isin(pd.date_range("2016/4/17", periods=75))] # [2016/4/17,2016/7/1)_ = off_train[ off_train["date"].isin(pd.date_range("2016/6/16", periods=15))] # [20160616,20160701)test_label_field = off_test.copy() # [20160701,20160801)Feature engineeringFeature engineering consumed the most time and effort and accounts for the largest share of this project’s code. See main.py for the complete implementation.History-segment featuresUser•Number of coupons received historically•Number of coupons redeemed historically•Historical coupon redemption rate•Number of coupons redeemed within 15 days historically•Historical 15-day redemption rate•Mean interval between coupon receipt and redemption, in days•Minimum interval between coupon receipt and redemption, in days•Maximum interval between coupon receipt and redemption, in days•Mean distance associated with received coupons•Maximum distance associated with received coupons•Minimum distance associated with received coupons•Mean discount rate of received coupons•Highest discount rate of received coupons•Lowest discount rate of received coupons•Mean discount rate of redeemed coupons•Highest discount rate of redeemed coupons•Lowest discount rate of redeemed coupons•Mean distance associated with coupons redeemed historically•Maximum distance associated with coupons redeemed historically•Minimum distance associated with coupons redeemed historically•Number of threshold-discount coupons redeemed•Number of non-threshold-discount coupons redeemed•Number of coupons received in the first third of the month•Number of coupons redeemed in the first third of the month•Redemption rate in the first third of the month•Number of coupons received in the middle third of the month•Number of coupons redeemed in the middle third of the month•Redemption rate in the middle third of the month•Number of coupons received in the last third of the month•Number of coupons redeemed in the last third of the month•Redemption rate in the last third of the month•Number of distinct merchants associated with received coupons•Number of distinct merchants associated with redeemed coupons•Number of distinct coupon types received•Number of distinct coupon types redeemedMerchant•Number of coupons received from the merchant•Number of threshold-discount coupons received•Number of non-threshold-discount coupons received•Number of coupon redemptions•Number of threshold-discount coupon redemptions•Number of non-threshold-discount coupon redemptions•Coupon redemption rate•Number of customers who received coupons•Number of customers who redeemed coupons•Number of coupon types offered•Mean coupon discount rate•Highest coupon discount rate•Lowest coupon discount rate•Mean distance associated with redeemed coupons•Maximum distance associated with redeemed coupons•Minimum distance associated with redeemed couponsCoupon•Number of times the coupon was received•Number of times the coupon was redeemed•Coupon redemption rate•Mean distance associated with coupon receipts•Maximum distance associated with coupon receipts•Minimum distance associated with coupon receipts•Mean distance associated with coupon redemptions•Maximum distance associated with coupon redemptions•Minimum distance associated with coupon redemptions•Number of redemptions within 15 days•15-day redemption rateUser + merchant•Historical number of coupons received by the user from the specified merchant•Historical number of coupons redeemed by the user at the specified merchant•Historical redemption rate for the user at the specified merchant•Historical number of redemptions within 15 days at the specified merchant•Historical 15-day redemption rate at the specified merchant•Mean receipt-to-redemption interval at the specified merchant, in days•Minimum receipt-to-redemption interval at the specified merchant, in days•Maximum receipt-to-redemption interval at the specified merchant, in daysMerchant + couponData analysis showed that every coupon corresponds to a unique merchant. Consequently, merchant + coupon features duplicate coupon features.•Number of receipts of this coupon from this merchant•Number of redemptions of this coupon at this merchant•Redemption rate for this coupon at this merchant•Number of redemptions of this coupon within 15 days at this merchant•15-day redemption rate for this coupon at this merchant•Mean distance for redemptions of this coupon at this merchant•Minimum distance for redemptions of this coupon at this merchant•Maximum distance for redemptions of this coupon at this merchantUser + coupon•Number of times the user received this coupon•Number of times the user redeemed this coupon•Redemption rate for this coupon and user•Number of times the user redeemed this coupon within 15 days•15-day redemption rate for this coupon and user•Mean receipt-to-redemption interval, in days•Minimum receipt-to-redemption interval, in days•Maximum receipt-to-redemption interval, in days•Mean distance associated with this user’s receipts of this coupon•Maximum distance associated with this user’s receipts of this coupon•Minimum distance associated with this user’s receipts of this coupon•Mean distance associated with this user’s redemptions of this coupon•Maximum distance associated with this user’s redemptions of this coupon•Minimum distance associated with this user’s redemptions of this couponUser + merchant + couponBecause each coupon corresponds to a unique merchant, user + merchant + coupon features duplicate user + coupon features.•Number of times the user received this merchant’s coupon•Number of times the user redeemed this merchant’s coupon•Redemption rate for this merchant’s coupon and user•Mean receipt-to-redemption interval, in days•Minimum receipt-to-redemption interval, in days•Maximum receipt-to-redemption interval, in daysLabel-segment featuresTime•Coupon-receipt day of week: integer + sin + cos + one hot•Coupon-receipt day of month: integer + sin + cos + one hot•Coupon-receipt month: integer•Whether the date is a day off•Whether the date is a weekend•Whether the date is the first working day•Whether the date is the last working day•Whether the date is the first day off•Whether the date is the last day off•Whether the date is a working day•Whether the date is in the first third of the month•Whether the date is in the middle third of the month•Whether the date is in the last third of the monthUser•Number of coupons received•Number of coupon types received•Number of threshold-discount coupons received•Number of threshold-discount coupon types received•Mean distance associated with received coupons•Minimum distance associated with received coupons•Maximum distance associated with received coupons•Difference between the receipt distance and the mean distanceMerchant•Number of coupon types issued•Number of coupons received from the merchantUser + merchant•Number of coupons received by the user from the specified merchant•Whether the user received the merchant’s coupons more than once•Number of threshold-discount coupons received from the merchant•Number of distinct coupon types received from the specified merchant•Mean distance associated with the user’s coupon receipts from the merchant•Minimum distance associated with the user’s coupon receipts from the merchant•Maximum distance associated with the user’s coupon receipts from the merchantUser + coupon•Number of times the user received the specified coupon•Whether the user received the specified coupon more than onceMerchant + coupon•Number of times the merchant’s specified coupon was receivedUser + merchant + couponThese duplicate user + coupon features.•Number of times the user received the specified coupon from the specified merchant•Whether the user received the specified coupon from the specified merchant more than onceUser + coupon-receipt date•Whether the user received coupons more than once on the same day•Number of coupons the user received that day•Number of coupons the user received before that day•Number of coupons the user received after that dayUser + coupon + coupon-receipt date•Whether the user received the specified coupon more than once on the same day•Number of times the user received the specified coupon that day•Number of times the user received the specified coupon before that day•Number of times the user received the specified coupon after that dayUser + merchant + coupon-receipt date•Whether the user received coupons from the specified merchant more than once that day•Number of coupons received from the specified merchant that day•Number of coupons received from the specified merchant before that day•Number of coupons received from the specified merchant after that dayUser + merchant + coupon + coupon-receipt dateThese duplicate user + coupon + coupon-receipt date features. However, removing them caused a significant decline in model performance.•Whether the user received the specified coupon from the specified merchant more than once that day•Number of times the user received the specified coupon from the specified merchant that day•Number of times the user received the specified coupon from the specified merchant before that day•Number of times the user received the specified coupon from the specified merchant after that dayOnline features•Total number of online actions by the user•Number of online clicks•Number of online purchases•Number of online coupon receipts•Online click rate•Online purchase rate•Online coupon-receipt rate•Number of online records marked fixed•Proportion of online records marked fixedCombined online and offline features•Ratio of offline coupon receipts to online coupon receipts; total number of coupons received from a specified merchant•Ratio of offline consumption to online consumptionFeatures from the complete dataset•Whether the user has never redeemed a couponModel ensemblingI used XGBoost and LightGBM, combining their predictions through rank-based ensembling.The weights were LightGBM: 0.8 and XGBoost: 0.2.See model.py for the complete implementation.Change historyEvery change can be traced through Git commits.A selection of commitsI will not list the entire change history here; all changes are recorded in Git commits. The screenshots retain the original commit messages and interface text.For example, VS Code’s built-in Git tools can display the changes in a commit.VS Code's built-in Git toolsCommits are also easy to inspect in the remote repository.Viewing commits on GitHub4.ReflectionsData determines the upper bound of machine learning; models and algorithms merely approach that bound.Early in the project, data analysis of online and offline activity revealed patterns such as the negative correlation between consumption distance and redemption rate, and the different effects of discount types—threshold discounts, non-threshold discounts, and online limited-time low prices—on consumer decisions. These findings gave me more directions and points of focus when I later constructed labels and extracted features.Feature engineering was the most time-consuming and productive stage of this project. While working to move AUC from 0.7206 to 0.8175, I built a multidimensional feature system covering users, merchants, and coupons, together with their pairwise and three-way interactions. Beyond basic features, I investigated aggregate features such as ratios between online and offline behavior and whether a user had ever redeemed a coupon across the full dataset. I also learned to select features through experiments, removing redundancy and duplicate features tightly bound to coupon identities to improve generalization and computational efficiency.Each coupon ID maps to a unique merchant ID. Therefore, in the label segment, user + merchant + coupon + receipt date features duplicate user + coupon + receipt date features. However, removing them significantly reduced model performance, so I had to abandon that change. (Black magic.)During model ensembling, I added LightGBM alongside the already strong baseline XGBoost model. I gained a much deeper appreciation of ensemble learning: the large amount of data produced through preprocessing and feature engineering is refined by the models to reveal useful patterns. I used a weighted rank-based combination, LightGBM 0.8 + XGBoost 0.2. In the final version, however, LightGBM performed significantly better on the test set than XGBoost, and blending them made the result worse. I therefore chose to use LightGBM’s predictions directly.Finally, a modern development environment and version-control tools greatly improved my efficiency. I worked on Archlinux/NixOS and developed with recent components such as Python 3.13. Strict Git version control made it possible to trace each small AUC improvement back to its underlying code changes. In my view, this disciplined engineering mindset matters just as much as algorithmic innovation.I also explored Data Wrangler, an official Microsoft extension for VS Code. It reads CSV files very quickly, automatically computes statistics such as mean, max, min, and distinct counts, and draws corresponding charts. By making visual analysis readily accessible, it substantially improved my data-analysis efficiency. Thanks to the Microsoft team!