{
  "id": 557208,
  "title": "Solution Overview - Feature Engineering + LightGBM",
  "content": "<h3>1. Data Loading and Initial Exploration</h3>\n<ul>\n<li>The training and test datasets were loaded using Pandas and explored for basic statistics, column distributions, and data types.</li>\n<li>Initial inspections revealed duplicate rows, missing values, and certain features needing transformations for consistency.</li>\n</ul>\n<hr>\n<h3>2. Data Preprocessing</h3>\n<h4>Duplicate Removal:</h4>\n<ul>\n<li>Duplicate rows were identified by excluding the <code>id</code> column and removed to avoid skewing the model with redundant information.</li>\n</ul>\n<h4>Data Cleaning:</h4>\n<ul>\n<li>The <code>user_id</code> column, which included a prefix (<code>****</code>), was cleaned using regular expressions and converted to integers. This transformation ensured consistency and enabled easier feature engineering.</li>\n</ul>\n<h4>Handling Missing Values:</h4>\n<ul>\n<li>Missing values in numerical features were imputed using median values to minimize the impact of outliers. For categorical features, missing values were treated as a separate category.</li>\n</ul>\n<hr>\n<h3>3. Outlier Detection and Treatment</h3>\n<ul>\n<li><p>Outliers were evaluated in key numerical columns such as:</p>\n<ul>\n<li><code>age</code></li>\n<li><code>Received_card_discount_percentage</code></li>\n<li><code>Received_coupon_discount_percentage</code></li>\n<li><code>Product_value</code></li></ul></li>\n<li><p>The treatment strategy depended on whether similar outliers were present in the test dataset. For instance, outliers were removed from the training data only if they did not appear in the test set, preventing model inaccuracies during inference.</p></li>\n</ul>\n<hr>\n<h3>4. Feature Engineering</h3>\n<h4>Encoding Techniques:</h4>\n<ul>\n<li><strong>Label Encoding</strong>: Applied to ordinal categorical variables, preserving the natural order of categories.</li>\n<li><strong>One-Hot Encoding</strong>: Used for nominal categorical variables to avoid imposing artificial relationships between categories.</li>\n<li><strong>Benefits</strong>: These encodings enabled LightGBM to handle categorical features natively, leading to faster training and better performance.</li>\n</ul>\n<h4>Feature Importance Analysis:</h4>\n<ul>\n<li><strong>Mutual Information (MI) Scores</strong>: Calculated to assess the dependency between features and the target variable. Features with low MI scores were considered for removal or transformation.</li>\n</ul>\n<h4>Derived Features:</h4>\n<ul>\n<li>Interaction terms between discount percentages and product values were generated, capturing the effect of combined discounts.</li>\n<li>Time-based features, such as day-of-week and hour-of-day, were extracted from timestamps to identify temporal patterns.</li>\n</ul>\n<hr>\n<h3>5. Model Selection and Training</h3>\n<h4>Choice of LightGBM:</h4>\n<ul>\n<li>LightGBM was selected for its ability to handle large datasets efficiently and its native support for categorical features.</li>\n<li>The framework’s gradient-boosting mechanism provided superior performance for this tabular dataset.</li>\n</ul>\n<h4>Hyperparameter Tuning:</h4>\n<ul>\n<li><p>Hyperparameters were optimized using Bayesian optimization, focusing on:</p>\n<ul>\n<li>Number of leaves</li>\n<li>Learning rate</li>\n<li>Max depth</li>\n<li>Feature fraction</li>\n<li>Bagging fraction</li></ul></li>\n<li><p>Cross-validation was employed to validate the model’s performance and minimize overfitting.</p></li>\n</ul>\n<hr>\n<h3>6. Model Evaluation and Submission</h3>\n<ul>\n<li>The model was evaluated on a hold-out validation set, with metrics such as accuracy, F1-score, and AUC monitored to ensure alignment with competition objectives.</li>\n<li>Predictions for the test dataset were generated and saved in the required submission format.</li>\n</ul>\n<hr>\n<h3>Challenges and Learnings</h3>\n<ul>\n<li><p>Encoding categorical features effectively was crucial for leveraging LightGBM’s capabilities.</p></li>\n<li><p>Treating outliers required careful cross-referencing with the test dataset to ensure consistency.</p></li>\n<li><p>Feature engineering, especially interaction terms and time-based features, significantly boosted model performance.</p></li>\n<li><p>I am grateful to <a href=\"https://www.kaggle.com/akinduhiman\" target=\"_blank\">@akinduhiman</a> for sharing discussion post that introduced the <code>received_weekday</code> feature and its application in capturing temporal patterns. This feature proved highly beneficial in improving model performance.</p></li>\n</ul>\n<p>My notebook : <a href=\"https://www.kaggle.com/code/bashithashamila/predict-the-customer-satisfaction-lightgbm\" target=\"_blank\">predict-the-customer-satisfaction-lightgbm</a></p>",
  "comments": [],
  "comment_count": 0,
  "messages": [
    {
      "id": 3099241,
      "postDate": "2025-01-17T13:54:22.380Z",
      "content": "<h3>1. Data Loading and Initial Exploration</h3>\n<ul>\n<li>The training and test datasets were loaded using Pandas and explored for basic statistics, column distributions, and data types.</li>\n<li>Initial inspections revealed duplicate rows, missing values, and certain features needing transformations for consistency.</li>\n</ul>\n<hr>\n<h3>2. Data Preprocessing</h3>\n<h4>Duplicate Removal:</h4>\n<ul>\n<li>Duplicate rows were identified by excluding the <code>id</code> column and removed to avoid skewing the model with redundant information.</li>\n</ul>\n<h4>Data Cleaning:</h4>\n<ul>\n<li>The <code>user_id</code> column, which included a prefix (<code>****</code>), was cleaned using regular expressions and converted to integers. This transformation ensured consistency and enabled easier feature engineering.</li>\n</ul>\n<h4>Handling Missing Values:</h4>\n<ul>\n<li>Missing values in numerical features were imputed using median values to minimize the impact of outliers. For categorical features, missing values were treated as a separate category.</li>\n</ul>\n<hr>\n<h3>3. Outlier Detection and Treatment</h3>\n<ul>\n<li><p>Outliers were evaluated in key numerical columns such as:</p>\n<ul>\n<li><code>age</code></li>\n<li><code>Received_card_discount_percentage</code></li>\n<li><code>Received_coupon_discount_percentage</code></li>\n<li><code>Product_value</code></li></ul></li>\n<li><p>The treatment strategy depended on whether similar outliers were present in the test dataset. For instance, outliers were removed from the training data only if they did not appear in the test set, preventing model inaccuracies during inference.</p></li>\n</ul>\n<hr>\n<h3>4. Feature Engineering</h3>\n<h4>Encoding Techniques:</h4>\n<ul>\n<li><strong>Label Encoding</strong>: Applied to ordinal categorical variables, preserving the natural order of categories.</li>\n<li><strong>One-Hot Encoding</strong>: Used for nominal categorical variables to avoid imposing artificial relationships between categories.</li>\n<li><strong>Benefits</strong>: These encodings enabled LightGBM to handle categorical features natively, leading to faster training and better performance.</li>\n</ul>\n<h4>Feature Importance Analysis:</h4>\n<ul>\n<li><strong>Mutual Information (MI) Scores</strong>: Calculated to assess the dependency between features and the target variable. Features with low MI scores were considered for removal or transformation.</li>\n</ul>\n<h4>Derived Features:</h4>\n<ul>\n<li>Interaction terms between discount percentages and product values were generated, capturing the effect of combined discounts.</li>\n<li>Time-based features, such as day-of-week and hour-of-day, were extracted from timestamps to identify temporal patterns.</li>\n</ul>\n<hr>\n<h3>5. Model Selection and Training</h3>\n<h4>Choice of LightGBM:</h4>\n<ul>\n<li>LightGBM was selected for its ability to handle large datasets efficiently and its native support for categorical features.</li>\n<li>The framework’s gradient-boosting mechanism provided superior performance for this tabular dataset.</li>\n</ul>\n<h4>Hyperparameter Tuning:</h4>\n<ul>\n<li><p>Hyperparameters were optimized using Bayesian optimization, focusing on:</p>\n<ul>\n<li>Number of leaves</li>\n<li>Learning rate</li>\n<li>Max depth</li>\n<li>Feature fraction</li>\n<li>Bagging fraction</li></ul></li>\n<li><p>Cross-validation was employed to validate the model’s performance and minimize overfitting.</p></li>\n</ul>\n<hr>\n<h3>6. Model Evaluation and Submission</h3>\n<ul>\n<li>The model was evaluated on a hold-out validation set, with metrics such as accuracy, F1-score, and AUC monitored to ensure alignment with competition objectives.</li>\n<li>Predictions for the test dataset were generated and saved in the required submission format.</li>\n</ul>\n<hr>\n<h3>Challenges and Learnings</h3>\n<ul>\n<li><p>Encoding categorical features effectively was crucial for leveraging LightGBM’s capabilities.</p></li>\n<li><p>Treating outliers required careful cross-referencing with the test dataset to ensure consistency.</p></li>\n<li><p>Feature engineering, especially interaction terms and time-based features, significantly boosted model performance.</p></li>\n<li><p>I am grateful to <a href=\"https://www.kaggle.com/akinduhiman\" target=\"_blank\">@akinduhiman</a> for sharing discussion post that introduced the <code>received_weekday</code> feature and its application in capturing temporal patterns. This feature proved highly beneficial in improving model performance.</p></li>\n</ul>\n<p>My notebook : <a href=\"https://www.kaggle.com/code/bashithashamila/predict-the-customer-satisfaction-lightgbm\" target=\"_blank\">predict-the-customer-satisfaction-lightgbm</a></p>",
      "rawMarkdown": "### 1. Data Loading and Initial Exploration \n- The training and test datasets were loaded using Pandas and explored for basic statistics, column distributions, and data types.\n- Initial inspections revealed duplicate rows, missing values, and certain features needing transformations for consistency.\n\n---\n\n###  2. Data Preprocessing \n#### Duplicate Removal:\n- Duplicate rows were identified by excluding the `id` column and removed to avoid skewing the model with redundant information.\n\n#### Data Cleaning:\n- The `user_id` column, which included a prefix (`****`), was cleaned using regular expressions and converted to integers. This transformation ensured consistency and enabled easier feature engineering.\n\n#### Handling Missing Values:\n- Missing values in numerical features were imputed using median values to minimize the impact of outliers. For categorical features, missing values were treated as a separate category.\n\n---\n\n### 3. Outlier Detection and Treatment \n- Outliers were evaluated in key numerical columns such as:\n  - `age`\n  - `Received_card_discount_percentage`\n  - `Received_coupon_discount_percentage`\n  - `Product_value`\n\n- The treatment strategy depended on whether similar outliers were present in the test dataset. For instance, outliers were removed from the training data only if they did not appear in the test set, preventing model inaccuracies during inference.\n\n---\n\n###  4. Feature Engineering \n#### Encoding Techniques:\n- **Label Encoding**: Applied to ordinal categorical variables, preserving the natural order of categories.\n- **One-Hot Encoding**: Used for nominal categorical variables to avoid imposing artificial relationships between categories.\n- **Benefits**: These encodings enabled LightGBM to handle categorical features natively, leading to faster training and better performance.\n\n#### Feature Importance Analysis:\n- **Mutual Information (MI) Scores**: Calculated to assess the dependency between features and the target variable. Features with low MI scores were considered for removal or transformation.\n\n#### Derived Features:\n- Interaction terms between discount percentages and product values were generated, capturing the effect of combined discounts.\n- Time-based features, such as day-of-week and hour-of-day, were extracted from timestamps to identify temporal patterns.\n\n---\n\n### 5. Model Selection and Training\n#### Choice of LightGBM:\n- LightGBM was selected for its ability to handle large datasets efficiently and its native support for categorical features.\n- The framework’s gradient-boosting mechanism provided superior performance for this tabular dataset.\n\n#### Hyperparameter Tuning:\n- Hyperparameters were optimized using Bayesian optimization, focusing on:\n  - Number of leaves\n  - Learning rate\n  - Max depth\n  - Feature fraction\n  - Bagging fraction\n\n- Cross-validation was employed to validate the model’s performance and minimize overfitting.\n\n---\n\n### 6. Model Evaluation and Submission\n- The model was evaluated on a hold-out validation set, with metrics such as accuracy, F1-score, and AUC monitored to ensure alignment with competition objectives.\n- Predictions for the test dataset were generated and saved in the required submission format.\n\n---\n\n### Challenges and Learnings \n\n- Encoding categorical features effectively was crucial for leveraging LightGBM’s capabilities.\n\n- Treating outliers required careful cross-referencing with the test dataset to ensure consistency.\n\n- Feature engineering, especially interaction terms and time-based features, significantly boosted model performance.\n\n- I am grateful to @akinduhiman for sharing discussion post that introduced the `received_weekday` feature and its application in capturing temporal patterns. This feature proved highly beneficial in improving model performance.\n\n\nMy notebook : [predict-the-customer-satisfaction-lightgbm](https://www.kaggle.com/code/bashithashamila/predict-the-customer-satisfaction-lightgbm)\n",
      "votes": 3
    }
  ],
  "complete": true,
  "source": "live",
  "fetched_at": "2026-10-19T13:43:33Z",
  "competition_id": 90922,
  "competition_slug": "Predict-the-Customer-Satisfaction-CSE-22",
  "team_id": 13200872,
  "solution_url": "/competitions/Predict-the-Customer-Satisfaction-CSE-22/writeups/bashitha-shamila-solution-overview-feature-enginee"
}