mayadeeb08 commited on
Commit
f588a1b
·
verified ·
1 Parent(s): 65adbc3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -43
README.md CHANGED
@@ -403,39 +403,47 @@ This helped reduce complexity and improve the efficiency of the modeling process
403
  ---
404
 
405
  ## Clustering Analysis
406
- K-Means clustering was used to create customer or transaction behavior segments.
407
 
408
- ### Features used for clustering:
 
 
 
409
  - `Unit_Price`
410
  - `Quantity`
411
  - `Discount_Percentage`
412
  - `Total_Before_Discount`
413
 
414
- The target variable `Total_Amount` was not included in clustering to avoid target leakage.
415
 
416
- ### Number of clusters
417
- K-Means was applied with **3 clusters**.
418
 
419
- ### Cluster features created:
420
- - `Purchase_Cluster`
421
- - `Distance_To_Cluster_Center`
422
- - `Cluster_Confidence`
423
 
424
- ### Cluster counts:
425
- | Cluster | Number of Transactions |
426
- |---|---:|
427
- | Cluster 0 | 10,712 |
428
- | Cluster 1 | 3,661 |
429
- | Cluster 2 | 2,676 |
430
 
431
- ### Cluster interpretation:
432
- - **Cluster 0:** Regular purchases with lower unit price, low discount percentage, and moderate total value before discount.
433
- - **Cluster 1:** Higher-value purchases with the highest average unit price and highest total before discount.
434
- - **Cluster 2:** Discount-driven purchases with the highest average quantity and much higher discount percentage.
 
 
 
 
 
435
 
436
  ### Main Insight
437
- The clusters represent different purchasing behavior patterns.
438
- Adding cluster-based features helped the models understand transaction types more effectively.
 
 
 
 
 
 
439
 
440
  ---
441
 
@@ -495,6 +503,8 @@ Three improved regression models were trained using the engineered dataset.
495
  | Random Forest Regressor | 21.80 | 9,397.69 | 96.94 | 0.9897 |
496
  | Gradient Boosting Regressor | 30.75 | 9,134.01 | 95.57 | 0.9900 |
497
 
 
 
498
  ### Regression winner
499
  The **Random Forest Regressor** was selected as the final regression model.
500
 
@@ -522,6 +532,8 @@ After completing the regression task, the original numerical target `Total_Amoun
522
  Quantile binning was used to create relatively balanced classes.
523
  The thresholds were calculated using only the training data to avoid data leakage and then applied to both training and testing sets.
524
 
 
 
525
  ### Class balance:
526
  | Class | Train Count | Train Percentage | Test Count | Test Percentage |
527
  |---|---:|---:|---:|---:|
@@ -529,6 +541,8 @@ The thresholds were calculated using only the training data to avoid data leakag
529
  | Medium Purchase | 4,546 | 33.33% | 1,154 | 33.84% |
530
  | High Purchase | 4,546 | 33.33% | 1,123 | 32.93% |
531
 
 
 
532
  ### Main Insight
533
  The classes are balanced because quantile binning was used.
534
  This makes accuracy useful, but macro F1-score was also used because it evaluates all classes equally.
@@ -562,6 +576,10 @@ Therefore, the evaluation focused on:
562
  | Random Forest Classifier | 0.9947 | 0.9947 | 0.9948 | 0.9947 |
563
  | Logistic Regression | 0.9633 | 0.9634 | 0.9635 | 0.9634 |
564
 
 
 
 
 
565
  ### Classification winner
566
  The **Gradient Boosting Classifier** was selected as the best classification model.
567
 
@@ -635,25 +653,3 @@ For regression, the Random Forest Regressor was selected as the final model beca
635
 
636
  Overall, the project shows that customer purchase value is shaped by multiple interacting factors. The dataset provides valuable insights for business decision-making, targeted marketing, inventory planning, customer segmentation, and predictive modeling.
637
 
638
- ---
639
-
640
- ## Files Included
641
- This Hugging Face model repository includes:
642
-
643
- - The original dataset file
644
- - The Jupyter Notebook (`.ipynb`)
645
- - The README file
646
- - `winning_model.pkl` — final regression model
647
- - `winning_classification_model.pkl` — final classification model
648
- - Presentation video link
649
-
650
- ---
651
-
652
- ## Repository Submission
653
- The final submission should be the Hugging Face model repository link, including:
654
-
655
- - README
656
- - Python Notebook
657
- - 1 pickle model for regression
658
- - 1 pickle model for classification
659
- - Video presentation
 
403
  ---
404
 
405
  ## Clustering Analysis
 
406
 
407
+ K-Means clustering was used to group transactions into different purchasing behavior segments.
408
+
409
+ The clustering was based on transaction-related features:
410
+
411
  - `Unit_Price`
412
  - `Quantity`
413
  - `Discount_Percentage`
414
  - `Total_Before_Discount`
415
 
416
+ The target variable, `Total_Amount`, was not used in the clustering process in order to avoid target leakage.
417
 
418
+ ### Clustering Results
 
419
 
420
+ The K-Means model created **3 clusters**:
 
 
 
421
 
422
+ | Cluster | Number of Transactions | Interpretation |
423
+ |---|---:|---|
424
+ | Cluster 0 | 10,712 | Regular purchases with lower prices and moderate purchase values |
425
+ | Cluster 1 | 3,661 | High-value purchases with higher unit prices and higher total amounts before discount |
426
+ | Cluster 2 | 2,676 | Discount-driven purchases with higher quantities and higher discount percentages |
 
427
 
428
+ ### Cluster-Based Features
429
+
430
+ After creating the clusters, three new features were added to the dataset:
431
+
432
+ | Feature | Meaning |
433
+ |---|---|
434
+ | `Purchase_Cluster` | The cluster assigned to each transaction |
435
+ | `Distance_To_Cluster_Center` | How far the transaction is from the center of its cluster |
436
+ | `Cluster_Confidence` | How strongly the transaction belongs to its assigned cluster |
437
 
438
  ### Main Insight
439
+
440
+ The clustering analysis helped identify three main types of purchasing behavior:
441
+
442
+ 1. Regular purchases
443
+ 2. High-value purchases
444
+ 3. Discount-driven purchases
445
+
446
+ These cluster-based features were later added to the modeling stage to help the models better understand different transaction patterns.
447
 
448
  ---
449
 
 
503
  | Random Forest Regressor | 21.80 | 9,397.69 | 96.94 | 0.9897 |
504
  | Gradient Boosting Regressor | 30.75 | 9,134.01 | 95.57 | 0.9900 |
505
 
506
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/69d6633b22cc2532d036e88e/S4GKFBBIEQLLwjRL58tyl.png)
507
+
508
  ### Regression winner
509
  The **Random Forest Regressor** was selected as the final regression model.
510
 
 
532
  Quantile binning was used to create relatively balanced classes.
533
  The thresholds were calculated using only the training data to avoid data leakage and then applied to both training and testing sets.
534
 
535
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/69d6633b22cc2532d036e88e/PZw8TpwY9Cx1pxbgAc3Sr.png)
536
+
537
  ### Class balance:
538
  | Class | Train Count | Train Percentage | Test Count | Test Percentage |
539
  |---|---:|---:|---:|---:|
 
541
  | Medium Purchase | 4,546 | 33.33% | 1,154 | 33.84% |
542
  | High Purchase | 4,546 | 33.33% | 1,123 | 32.93% |
543
 
544
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/69d6633b22cc2532d036e88e/C0uEsn_J7NuUTFRHDPzL4.png)
545
+
546
  ### Main Insight
547
  The classes are balanced because quantile binning was used.
548
  This makes accuracy useful, but macro F1-score was also used because it evaluates all classes equally.
 
576
  | Random Forest Classifier | 0.9947 | 0.9947 | 0.9948 | 0.9947 |
577
  | Logistic Regression | 0.9633 | 0.9634 | 0.9635 | 0.9634 |
578
 
579
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/69d6633b22cc2532d036e88e/x1fiI8mqH479yVk3jdNHP.png)
580
+
581
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/69d6633b22cc2532d036e88e/CNPHT6QHfh_NdXGq-HmFf.png)
582
+
583
  ### Classification winner
584
  The **Gradient Boosting Classifier** was selected as the best classification model.
585
 
 
653
 
654
  Overall, the project shows that customer purchase value is shaped by multiple interacting factors. The dataset provides valuable insights for business decision-making, targeted marketing, inventory planning, customer segmentation, and predictive modeling.
655