Q4
Q4
Marketing & Strategy Analytics Term One, 2024-2025 WARWICK BUSINESS SCHOOL
Declaration
This is to certify that the work I am submitting is my own. All external references and
sources are clearly acknowledged and identified within the contents. I am aware of the
University of Warwick regulation concerning plagiarism and collusion.
No substantial part(s) of the work submitted here has also been submitted by me in other
assessments for accredited courses of study, and I acknowledge that if this has been
done an appropriate reduction in the mark I might otherwise have received will be made.
Q1
Overview of ASOS
The company ASOS is a multinational online apparel store that primarily targets the ones in the
age group of 18-35. Widely regarded for its extensive range of products and devotion to
diversity. For the digitally native customers who prefer inexpensive but fashionable attire, ASOS
provides a unique and easy experience while buying clothes.
Analytic tools are used by ASOS to monitor customer engagement on sites like TikTok and
Instagram based on the ongoing trends. For instance, it’s #AsSeenOnMe campaign motivated
users to style the ASOS products and share these looks online. This drove a 20% rise and user
generated content engagement along with tremendously increasing their brand visibility.
Insights from a campaign like this help brands come up with strategies for trending product
segments.
ASOS makes sure to market to the target audience through keyword analysis and dynamic ad
optimization. For example, their Black Friday, Google Ad Campaign used real time, bidding
strategies and their customers, historical purchase data which led to a 40% increase in click-
through rates (CTR). ASOS enhanced its ad copy and visuals for better performance by using
A/B testing.
Customers’ browsing history, cart abandonment, and past purchases are analyzed by using
machine learning algorithms. This gives rise to personalized product, recommendations and
push notifications. For example, if customers are browsing, formal way often shown related
suggestions and discount offers, increasing conversion rates by 30%. Shopping becomes
seamless and relevant for each user by these data driven personalization efforts.
ASOS makes sure there is a cohesive and encouraging shopping experience that boost
customer loyalty and maximize sales by integrating their insights from multiple platforms.
1. Model Description
ASOS is able to identify various buyer profiles for adjusted marketing strategies using the K-
Means where individuals are grouped in clusters with sort of similar qualities this reduces intra-
cluster variance.
Based on closeness to centroids data points are allotted to the given clusters.
Until the clusters stabilize the centroids are again calculated repeatedly
Interaction Indicators: Company App usage, email engagement, and digital media based
activity.
Seasonal Based Trends: Buying approach at the time of holidays and other significant events.
3. Anticipated Results
Ensuring efficient inventory management through forecasting demand for certain categories or
items.
Marketing strategies aimed to customize to specific preferences for clusters, rise in the ROI of
campaigns.
Formation of relevant buyer groups such as shoppers who are budget-conscious, setting trends
and frequent buyers.
4. Applicability
K-Means is an ideal choice for ASOS because of its diverse range of customers and
dependence on personalizing items. As seen in the case of buyers frequently purchasing urban
clothes are often offered discounts exclusively designed for them at the same time access is
provided in advance to latest garments.
Marketing analytics must be aligned with moral practices to build trust among the customers.
1. Privacy of Data
Customers should have the choice to decide whether to allow data tracking or not. Regulations
like CCPA (Central Consumer Protection Authority) and GDPR (General Data Protection
Regulation) must be adhered to by not disclosing about personal information and practicing
openness regarding the means used to collect it and for usage.
Constant audits and wide range of training datasets are vital to control practices which are
exclusionary. Preferences like favoring high-value customers might be amplified not intentionally
by models like K-Means.
3. Security of Data
It is crucial to use strong cyber security measures in order to protect private information of the
clients. Legal implications and an overall decrease in trustworthiness might arise due to breach
of trust.
ASOS should seek permission to get information related to usage of data and thoroughly
convey the procedures. Educating them on the advantages of services which are personalized
helps to build trust and encourages the data to be shared.
ASOS might wisely make use of analytical data while maintaining customer relationships by
regarding such moral concerns.
Conclusion
Q2
Source Window
install.packages("readr")
library(readr)
#Loading the data set
EcoHome_Sales_Data<- read.csv("EcoHome_Sales_Data.csv")
#Using Discount offered as a factor
EcoHome_Sales_Data$discount_offered<-as.factor(EcoHome_Sales_Data$discount_offered)
EcoHome_Sales_Data$purchase_value<-as.numeric(EcoHome_Sales_Data$purchase_value)
#Putting linear regresion model
lrmodel <-lm(purchase_value~discount_offered,data=EcoHome_Sales_Data)
#Model summary
summary(lrmodel)
#Using multiple regression
lrmodeln<-
lm(purchase_value~discount_offered+age+product_type+units_past_purchase+spent_last_purc
hase+EcoHome_Sales_Data$income+EcoHome_Sales_Data$ad_exposure,data=EcoHome_S
ales_Data)
#Summarising the model
summary(lrmodeln)
#Checking residuals of the model (optional step useful for validation)
plot(lrmodel$residuals,main="residuals of the linear regression model", ylab = "residuals",
xlab="fitted values")
abline(h=0, col="green")
plot(lrmodeln$residuals,main="residuals of the linear regression model", ylab = "residuals",
xlab="fitted values")
abline(h=0, col="red")
Console Window
Part A
A Linear Regression Model is applied to determine whether discounts being extended has an
impact on the purchase value or not, that is, (lm(purchase_value ~ discount_offered)).
For discount_offered the coefficient derived is negative. This implies that the purchase
value decreases when discounts are offered.
As observed the p-value is more than 0.05 for discount_offered, proving that this effect
is of statistical insignificance.
The adjusted R² is satisfactory. This underlines the importance of other factors which are
equally important other than discounts contributing to rise in the purchase value.
2. Residual Analysis:
Part B
1. Types of Products:
The focus should be on product categories with high-margin where the company can earn
higher returns without compromising on profitability aspect. Substantial discounts can be offered
to essential products in order to attract those customers who are price-sensitive on the other
hand, premium or luxury goods generally need smaller amount of discounts to drive purchases.
2. Advertising Synergies:
To broaden their impact, EcoHome must integrate its offers with the advertising initiatives. As a
result of targeted digital advertisements for certain groups of the society increases both
purchase values and engagement.
A/B testing is useful for evaluating the correct level of discount that boosts the purchase value at
the same point of time ensuring profitability. This ensures discounts to remain powerful without
unnecessarily lowering margins.
4. Demography of Consumers:
Certain demographic groups react in different ways to discounts. Younger clients are likely to be
more sensitive towards price and respond better to discounts items that are trendy and
affordable. On the other hand, older customers normally prefer discounts on products which are
premium or are of high-quality. In addition to this, high-income customers create higher
purchase values. This makes them the best possible group for discounting campaigns and
personalized marketing
Discounts can be paired with loyalty programs to induce purchases which are repeated. For
instance by offering extra rewards or better discounts for those who frequently buy or have high-
spending capacity fosters greater customer loyalty and uplifts long-term sales.
Conclusion: EcoHome can derive favourable purchase value and achieve profitability by
positioning the types of products, customer demographics and systematically advertising.
Q3.
Source Code
# Loading libraries
install.packages("dplyr")
install.packages("ggplot2")
install.packages("cluster")
install.packages("factoextra")
library(dplyr)
library(ggplot2)
library(cluster)
library(factoextra)
# Cleaning data set
VData_clean <- VitaHealth_Customer_Data %>% select(-id, -gender, -product_category)
VData_clean
# Data normalising
VData_scale <- scale(VData_clean)
VData_scale
# Numbering Clusters
set.seed(123)
fviz_nbclust(VHCData_scale, kmeans, method = "wss") + ggtitle("Elbow Method to Determine
Optimal Clusters")
# Use-means with k (i.e. 3 clusters)
set.seed(123)
kmeans_result <- kmeans(VHCData_scale, centers = 3, nstart = 25)
# Adding cluster labels
VData_clean$Cluster <- as.factor(kmeans_result$cluster)
# Visualizing clusters
fviz_cluster(kmeans_result, data = VHCData_scale) + ggtitle("Elbow Method to Determine Optimal
Clusters")
csummary <- VData_clean %>% group_by(Cluster) %>%
summarise(across(everything(), mean))
csummary
Console Window
> #Loading libraries
> install.packages("dplyr")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and
install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/xps/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/dplyr_1.1.4.zip'
Content type 'application/zip' length 1561160 bytes (1.5 MB)
downloaded 1.5 MB
package ‘dplyr’ successfully unpacked and MD5 sums checked
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/xps/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/ggplot2_3.5.1.zip'
Content type 'application/zip' length 4955653 bytes (4.7 MB)
downloaded 4.7 MB
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/xps/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
filter, lag
Warning message:
package ‘dplyr’ was built under R version 4.2.3
> library(ggplot2)
Warning message:
package ‘ggplot2’ was built under R version 4.2.3
> library(cluster)
Warning message:
package ‘cluster’ was built under R version 4.2.3
> library(factoextra)
Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
Warning message:
package ‘factoextra’ was built under R version 4.2.3
> #Cleaning data set
> VData_clean <- VitaHealth_Customer_Data %>% select(-id, -gender, -product_category)
> VData_clean
age annual_spend purchase_frequency website_engagement newsletter_engagement
annual_spend_in_USD
1 21 516 2 6 26 645.00
2 21 962 1 5 36 1202.50
3 25 738 1 9 27 922.50
4 18 732 1 7 35 915.00
5 23 962 1 9 34 1202.50
6 21 533 2 7 39 666.25
7 24 737 2 7 34 921.25
8 25 586 2 10 40 732.50
9 24 847 2 5 33 1058.75
10 23 870 1 10 20 1087.50
11 22 931 2 9 39 1163.75
12 24 908 1 9 32 1135.00
13 19 893 2 7 24 1116.25
14 25 666 2 10 20 832.50
15 22 645 1 6 24 806.25
16 19 919 2 10 33 1148.75
17 20 666 1 9 29 832.50
18 25 507 2 5 27 633.75
19 18 549 2 8 24 686.25
20 18 945 1 6 23 1181.25
21 20 905 2 6 36 1131.25
22 25 582 1 8 21 727.50
23 22 711 1 8 35 888.75
24 23 893 1 9 22 1116.25
25 19 990 1 7 29 1237.50
26 18 661 2 10 31 826.25
27 22 641 2 7 31 801.25
28 18 587 2 8 35 733.75
29 18 932 1 8 23 1165.00
30 19 883 2 7 22 1103.75
31 19 853 2 5 22 1066.25
32 20 961 2 6 32 1201.25
33 20 598 2 5 24 747.50
34 24 742 1 6 27 927.50
35 21 660 2 7 22 825.00
36 19 650 2 5 27 812.50
37 22 911 2 9 20 1138.75
38 21 704 1 6 37 880.00
39 25 514 1 10 37 642.50
40 23 873 2 8 22 1091.25
41 24 941 2 9 33 1176.25
42 20 946 1 8 40 1182.50
43 24 802 1 7 22 1002.50
44 22 934 1 6 28 1167.50
45 20 877 1 9 29 1096.25
46 20 804 2 9 25 1005.00
47 24 777 2 6 23 971.25
48 19 748 2 9 33 935.00
49 25 770 2 9 27 962.50
50 22 799 2 8 40 998.75
51 23 718 1 8 20 897.50
52 23 678 2 6 30 847.50
53 20 657 2 7 37 821.25
54 22 760 2 9 30 950.00
55 23 803 1 7 28 1003.75
56 19 605 2 9 29 756.25
57 22 780 1 7 27 975.00
58 24 655 2 8 34 818.75
59 24 744 1 7 32 930.00
60 22 839 1 10 27 1048.75
61 24 748 1 5 24 935.00
62 19 950 2 8 21 1187.50
63 25 679 2 6 39 848.75
64 18 617 2 6 21 771.25
65 23 924 1 7 23 1155.00
66 21 868 2 7 40 1085.00
67 22 889 1 9 20 1111.25
68 24 852 2 7 30 1065.00
69 23 836 2 10 22 1045.00
70 22 836 2 6 34 1045.00
71 19 518 2 10 20 647.50
72 23 812 1 10 33 1015.00
73 25 802 1 7 25 1002.50
74 25 542 2 10 37 677.50
75 24 512 2 10 32 640.00
76 20 967 2 8 20 1208.75
77 23 550 1 10 20 687.50
78 23 567 2 8 23 708.75
79 25 730 2 10 29 912.50
80 22 938 1 8 21 1172.50
81 19 782 1 10 24 977.50
82 22 804 2 5 28 1005.00
83 25 973 2 8 31 1216.25
84 24 659 1 6 27 823.75
85 24 848 1 9 20 1060.00
86 23 675 1 10 36 843.75
87 22 552 1 8 23 690.00
88 24 936 2 5 23 1170.00
89 18 941 1 8 38 1176.25
90 23 943 2 10 39 1178.75
91 23 808 2 10 36 1010.00
92 19 773 2 9 34 966.25
93 22 734 1 9 24 917.50
94 19 939 1 6 27 1173.75
95 19 816 2 8 30 1020.00
96 25 975 1 7 20 1218.75
97 19 536 2 8 28 670.00
98 22 663 1 7 40 828.75
99 22 636 1 8 38 795.00
100 25 981 1 5 24 1226.25
101 25 818 2 6 32 1022.50
102 19 672 1 5 27 840.00
103 24 606 1 9 25 757.50
104 23 737 2 8 35 921.25
105 25 853 1 6 20 1066.25
106 21 745 1 5 38 931.25
107 25 640 2 6 34 800.00
108 25 687 2 7 27 858.75
109 24 576 2 5 30 720.00
110 21 791 2 5 40 988.75
111 24 958 2 7 40 1197.50
112 23 982 1 5 22 1227.50
113 18 733 2 9 27 916.25
114 25 588 1 9 27 735.00
115 18 852 1 7 27 1065.00
116 23 892 2 9 35 1115.00
117 18 529 2 8 34 661.25
118 22 554 2 7 36 692.50
119 22 860 2 8 29 1075.00
120 22 590 2 5 40 737.50
121 19 918 1 9 24 1147.50
122 20 960 2 6 26 1200.00
123 20 922 1 9 31 1152.50
124 18 508 1 6 28 635.00
125 21 692 2 9 26 865.00
126 23 653 2 8 40 816.25
127 23 814 2 10 37 1017.50
128 24 941 2 6 36 1176.25
129 23 648 1 9 39 810.00
130 19 614 1 6 34 767.50
131 22 756 1 6 40 945.00
132 25 689 1 7 36 861.25
133 20 733 1 5 24 916.25
134 24 820 1 6 20 1025.00
135 23 615 1 10 24 768.75
136 24 862 2 6 34 1077.50
137 19 896 1 5 32 1120.00
138 19 871 2 6 26 1088.75
139 23 568 2 9 26 710.00
140 18 921 1 10 23 1151.25
141 25 504 1 8 25 630.00
142 23 823 2 5 30 1028.75
143 21 528 1 8 32 660.00
144 20 858 2 10 23 1072.50
145 24 853 2 8 40 1066.25
146 20 539 2 5 35 673.75
147 19 879 1 5 40 1098.75
148 20 710 1 6 33 887.50
149 24 506 1 7 32 632.50
150 18 614 1 7 33 767.50
151 19 577 2 10 24 721.25
152 18 748 2 6 35 935.00
153 25 927 1 8 39 1158.75
154 19 587 2 9 29 733.75
155 24 605 2 6 38 756.25
156 22 562 2 7 33 702.50
157 25 907 1 7 29 1133.75
158 20 819 1 9 23 1023.75
159 18 917 1 6 27 1146.25
160 22 977 1 5 25 1221.25
161 20 739 2 9 37 923.75
162 25 978 1 9 22 1222.50
163 23 936 1 5 29 1170.00
164 20 731 1 6 23 913.75
165 23 536 2 9 21 670.00
166 19 860 1 6 28 1075.00
[ reached 'max' / getOption("max.print") -- omitted 11834 rows ]
> #Data normalising
> VData_scale <- scale(VData_clean)
> VData_scale
age annual_spend purchase_frequency website_engagement newsletter_engagement
[1,] -1.21664853 -1.0774232130 -0.98488939 -1.34592200 -1.47697982
[2,] -1.21664853 -0.9800244938 -1.28771487 -1.42183663 -1.04741398
[3,] -0.93430208 -1.0289422362 -1.28771487 -1.11817813 -1.43402324
[4,] -1.42840838 -1.0302525328 -1.28771487 -1.27000738 -1.09037056
[5,] -1.07547530 -0.9800244938 -1.28771487 -1.11817813 -1.13332715
[6,] -1.21664853 -1.0737107058 -0.98488939 -1.27000738 -0.91854423
[7,] -1.00488869 -1.0291606189 -0.98488939 -1.27000738 -1.13332715
[8,] -0.93430208 -1.0621364185 -0.98488939 -1.04226351 -0.87558764
[9,] -1.00488869 -1.0051385133 -0.98488939 -1.42183663 -1.17628373
[10,] -1.07547530 -1.0001157094 -1.28771487 -1.04226351 -1.73471933
[11,] -1.14606192 -0.9867943599 -0.98488939 -1.11817813 -0.91854423
[12,] -1.00488869 -0.9918171638 -1.28771487 -1.11817813 -1.21924032
[13,] -1.35782176 -0.9950929055 -0.98488939 -1.27000738 -1.56289299
[14,] -0.93430208 -1.0446657962 -0.98488939 -1.04226351 -1.73471933
[15,] -1.14606192 -1.0492518346 -1.28771487 -1.34592200 -1.56289299
[16,] -1.35782176 -0.9894149532 -0.98488939 -1.04226351 -1.17628373
[17,] -1.28723515 -1.0446657962 -1.28771487 -1.11817813 -1.34811007
[18,] -0.93430208 -1.0793886580 -0.98488939 -1.42183663 -1.43402324
[19,] -1.42840838 -1.0702165813 -0.98488939 -1.19409275 -1.56289299
[20,] -1.42840838 -0.9837370010 -1.28771487 -1.34592200 -1.60584958
[21,] -1.28723515 -0.9924723121 -0.98488939 -1.34592200 -1.04741398
[22,] -0.93430208 -1.0630099496 -1.28771487 -1.19409275 -1.69176275
[23,] -1.14606192 -1.0348385712 -1.28771487 -1.19409275 -1.09037056
[24,] -1.07547530 -0.9950929055 -1.28771487 -1.11817813 -1.64880616
[25,] -1.35782176 -0.9739097760 -1.28771487 -1.27000738 -1.34811007
[26,] -1.42840838 -1.0457577101 -0.98488939 -1.04226351 -1.26219690
[27,] -1.14606192 -1.0501253657 -0.98488939 -1.27000738 -1.26219690
[28,] -1.42840838 -1.0619180357 -0.98488939 -1.19409275 -1.09037056
[29,] -1.42840838 -0.9865759771 -1.28771487 -1.19409275 -1.60584958
[30,] -1.35782176 -0.9972767333 -0.98488939 -1.27000738 -1.64880616
[31,] -1.35782176 -1.0038282166 -0.98488939 -1.42183663 -1.64880616
[32,] -1.28723515 -0.9802428765 -0.98488939 -1.34592200 -1.21924032
[33,] -1.28723515 -1.0595158252 -0.98488939 -1.42183663 -1.56289299
[34,] -1.00488869 -1.0280687050 -1.28771487 -1.34592200 -1.43402324
[35,] -1.21664853 -1.0459760929 -0.98488939 -1.27000738 -1.64880616
[36,] -1.35782176 -1.0481599207 -0.98488939 -1.42183663 -1.43402324
[37,] -1.14606192 -0.9911620155 -0.98488939 -1.11817813 -1.73471933
[38,] -1.21664853 -1.0363672506 -1.28771487 -1.34592200 -1.00445739
[39,] -0.93430208 -1.0778599786 -1.28771487 -1.04226351 -1.00445739
[40,] -1.07547530 -0.9994605610 -0.98488939 -1.19409275 -1.64880616
[41,] -1.00488869 -0.9846105321 -0.98488939 -1.11817813 -1.17628373
[42,] -1.28723515 -0.9835186182 -1.28771487 -1.19409275 -0.87558764
[43,] -1.00488869 -1.0149657383 -1.28771487 -1.27000738 -1.64880616
[44,] -1.14606192 -0.9861392116 -1.28771487 -1.34592200 -1.39106665
[45,] -1.28723515 -0.9985870299 -1.28771487 -1.11817813 -1.34811007
[46,] -1.28723515 -1.0145289728 -0.98488939 -1.11817813 -1.51993641
[47,] -1.00488869 -1.0204253078 -0.98488939 -1.34592200 -1.60584958
[48,] -1.35782176 -1.0267584084 -0.98488939 -1.11817813 -1.17628373
[49,] -0.93430208 -1.0219539872 -0.98488939 -1.11817813 -1.43402324
[50,] -1.14606192 -1.0156208867 -0.98488939 -1.19409275 -0.87558764
[51,] -1.07547530 -1.0333098917 -1.28771487 -1.19409275 -1.73471933
[52,] -1.07547530 -1.0420452029 -0.98488939 -1.34592200 -1.30515349
[53,] -1.28723515 -1.0466312412 -0.98488939 -1.27000738 -1.00445739
[54,] -1.14606192 -1.0241378150 -0.98488939 -1.11817813 -1.30515349
[55,] -1.07547530 -1.0147473556 -1.28771487 -1.27000738 -1.39106665
[56,] -1.35782176 -1.0579871457 -0.98488939 -1.11817813 -1.34811007
[57,] -1.14606192 -1.0197701595 -1.28771487 -1.27000738 -1.43402324
[58,] -1.00488869 -1.0470680068 -0.98488939 -1.19409275 -1.13332715
[59,] -1.00488869 -1.0276319395 -1.28771487 -1.27000738 -1.21924032
[60,] -1.14606192 -1.0068855755 -1.28771487 -1.04226351 -1.43402324
[61,] -1.00488869 -1.0267584084 -1.28771487 -1.42183663 -1.56289299
[62,] -1.35782176 -0.9826450871 -0.98488939 -1.19409275 -1.69176275
[63,] -0.93430208 -1.0418268201 -0.98488939 -1.34592200 -0.91854423
[64,] -1.42840838 -1.0553665524 -0.98488939 -1.34592200 -1.69176275
[65,] -1.07547530 -0.9883230393 -1.28771487 -1.27000738 -1.60584958
[66,] -1.21664853 -1.0005524749 -0.98488939 -1.27000738 -0.87558764
[67,] -1.14606192 -0.9959664366 -1.28771487 -1.11817813 -1.73471933
[68,] -1.00488869 -1.0040465994 -0.98488939 -1.27000738 -1.30515349
[69,] -1.07547530 -1.0075407239 -0.98488939 -1.04226351 -1.64880616
[70,] -1.14606192 -1.0075407239 -0.98488939 -1.34592200 -1.13332715
[71,] -1.35782176 -1.0769864475 -0.98488939 -1.04226351 -1.73471933
[72,] -1.07547530 -1.0127819105 -1.28771487 -1.04226351 -1.17628373
[73,] -0.93430208 -1.0149657383 -1.28771487 -1.27000738 -1.51993641
[74,] -0.93430208 -1.0717452608 -0.98488939 -1.04226351 -1.00445739
[75,] -1.00488869 -1.0782967441 -0.98488939 -1.04226351 -1.21924032
[76,] -1.28723515 -0.9789325799 -0.98488939 -1.19409275 -1.73471933
[77,] -1.07547530 -1.0699981985 -1.28771487 -1.04226351 -1.73471933
[78,] -1.07547530 -1.0662856913 -0.98488939 -1.19409275 -1.60584958
[79,] -0.93430208 -1.0306892984 -0.98488939 -1.04226351 -1.34811007
[80,] -1.14606192 -0.9852656804 -1.28771487 -1.19409275 -1.69176275
[81,] -1.35782176 -1.0193333939 -1.28771487 -1.04226351 -1.56289299
[82,] -1.14606192 -1.0145289728 -0.98488939 -1.42183663 -1.39106665
[83,] -0.93430208 -0.9776222832 -0.98488939 -1.19409275 -1.26219690
[84,] -1.00488869 -1.0461944757 -1.28771487 -1.34592200 -1.43402324
[85,] -1.00488869 -1.0049201305 -1.28771487 -1.11817813 -1.73471933
[86,] -1.07547530 -1.0427003512 -1.28771487 -1.04226351 -1.04741398
[87,] -1.14606192 -1.0695614330 -1.28771487 -1.19409275 -1.60584958
[88,] -1.00488869 -0.9857024460 -0.98488939 -1.42183663 -1.60584958
[89,] -1.42840838 -0.9846105321 -1.28771487 -1.19409275 -0.96150081
[90,] -1.07547530 -0.9841737665 -0.98488939 -1.04226351 -0.91854423
[91,] -1.07547530 -1.0136554417 -0.98488939 -1.04226351 -1.04741398
[92,] -1.35782176 -1.0212988389 -0.98488939 -1.11817813 -1.13332715
[93,] -1.14606192 -1.0298157673 -1.28771487 -1.11817813 -1.56289299
[94,] -1.35782176 -0.9850472977 -1.28771487 -1.34592200 -1.43402324
[95,] -1.35782176 -1.0119083794 -0.98488939 -1.19409275 -1.30515349
[96,] -0.93430208 -0.9771855176 -1.28771487 -1.27000738 -1.73471933
[97,] -1.35782176 -1.0730555574 -0.98488939 -1.19409275 -1.39106665
[98,] -1.14606192 -1.0453209446 -1.28771487 -1.27000738 -0.87558764
[99,] -1.14606192 -1.0512172796 -1.28771487 -1.19409275 -0.96150081
[100,] -0.93430208 -0.9758752210 -1.28771487 -1.42183663 -1.56289299
[101,] -0.93430208 -1.0114716139 -0.98488939 -1.34592200 -1.21924032
[102,] -1.35782176 -1.0433554996 -1.28771487 -1.42183663 -1.43402324
[103,] -1.00488869 -1.0577687629 -1.28771487 -1.11817813 -1.51993641
[104,] -1.07547530 -1.0291606189 -0.98488939 -1.19409275 -1.09037056
[105,] -0.93430208 -1.0038282166 -1.28771487 -1.34592200 -1.73471933
[106,] -1.21664853 -1.0274135567 -1.28771487 -1.42183663 -0.96150081
[107,] -0.93430208 -1.0503437485 -0.98488939 -1.34592200 -1.13332715
[108,] -0.93430208 -1.0400797579 -0.98488939 -1.27000738 -1.43402324
[109,] -1.00488869 -1.0643202463 -0.98488939 -1.42183663 -1.30515349
[110,] -1.21664853 -1.0173679489 -0.98488939 -1.42183663 -0.87558764
[111,] -1.00488869 -0.9808980249 -0.98488939 -1.27000738 -0.87558764
[112,] -1.07547530 -0.9756568382 -1.28771487 -1.42183663 -1.64880616
[113,] -1.42840838 -1.0300341501 -0.98488939 -1.11817813 -1.43402324
[114,] -0.93430208 -1.0616996530 -1.28771487 -1.11817813 -1.43402324
[115,] -1.42840838 -1.0040465994 -1.28771487 -1.27000738 -1.43402324
[116,] -1.07547530 -0.9953112883 -0.98488939 -1.11817813 -1.09037056
[117,] -1.42840838 -1.0745842369 -0.98488939 -1.19409275 -1.13332715
[118,] -1.14606192 -1.0691246674 -0.98488939 -1.27000738 -1.04741398
[119,] -1.14606192 -1.0022995372 -0.98488939 -1.19409275 -1.34811007
[120,] -1.14606192 -1.0612628874 -0.98488939 -1.42183663 -0.87558764
[121,] -1.35782176 -0.9896333360 -1.28771487 -1.11817813 -1.56289299
[122,] -1.28723515 -0.9804612593 -0.98488939 -1.34592200 -1.47697982
[123,] -1.28723515 -0.9887598049 -1.28771487 -1.11817813 -1.26219690
[124,] -1.42840838 -1.0791702752 -1.28771487 -1.34592200 -1.39106665
[125,] -1.21664853 -1.0389878440 -0.98488939 -1.11817813 -1.47697982
[126,] -1.07547530 -1.0475047723 -0.98488939 -1.19409275 -0.87558764
[127,] -1.07547530 -1.0123451450 -0.98488939 -1.04226351 -1.00445739
[128,] -1.00488869 -0.9846105321 -0.98488939 -1.34592200 -1.04741398
[129,] -1.07547530 -1.0485966862 -1.28771487 -1.11817813 -0.91854423
[130,] -1.35782176 -1.0560217007 -1.28771487 -1.34592200 -1.13332715
[131,] -1.14606192 -1.0250113461 -1.28771487 -1.34592200 -0.87558764
[132,] -0.93430208 -1.0396429923 -1.28771487 -1.27000738 -1.04741398
[133,] -1.28723515 -1.0300341501 -1.28771487 -1.42183663 -1.56289299
[134,] -1.00488869 -1.0110348483 -1.28771487 -1.34592200 -1.73471933
[135,] -1.07547530 -1.0558033179 -1.28771487 -1.04226351 -1.56289299
[136,] -1.00488869 -1.0018627716 -0.98488939 -1.34592200 -1.13332715
[137,] -1.35782176 -0.9944377571 -1.28771487 -1.42183663 -1.21924032
[138,] -1.35782176 -0.9998973266 -0.98488939 -1.34592200 -1.47697982
[139,] -1.07547530 -1.0660673085 -0.98488939 -1.11817813 -1.47697982
[140,] -1.42840838 -0.9889781877 -1.28771487 -1.04226351 -1.60584958
[141,] -0.93430208 -1.0800438064 -1.28771487 -1.19409275 -1.51993641
[142,] -1.07547530 -1.0103797000 -0.98488939 -1.42183663 -1.30515349
[143,] -1.21664853 -1.0748026197 -1.28771487 -1.19409275 -1.21924032
[144,] -1.28723515 -1.0027363027 -0.98488939 -1.04226351 -1.60584958
[145,] -1.00488869 -1.0038282166 -0.98488939 -1.19409275 -0.87558764
[146,] -1.28723515 -1.0724004091 -0.98488939 -1.42183663 -1.09037056
[147,] -1.35782176 -0.9981502644 -1.28771487 -1.42183663 -0.87558764
[148,] -1.28723515 -1.0350569540 -1.28771487 -1.34592200 -1.17628373
[149,] -1.00488869 -1.0796070408 -1.28771487 -1.27000738 -1.21924032
[150,] -1.42840838 -1.0560217007 -1.28771487 -1.27000738 -1.17628373
[151,] -1.35782176 -1.0641018635 -0.98488939 -1.04226351 -1.56289299
[152,] -1.42840838 -1.0267584084 -0.98488939 -1.34592200 -1.09037056
[153,] -0.93430208 -0.9876678910 -1.28771487 -1.19409275 -0.91854423
[154,] -1.35782176 -1.0619180357 -0.98488939 -1.11817813 -1.34811007
[155,] -1.00488869 -1.0579871457 -0.98488939 -1.34592200 -0.96150081
[156,] -1.14606192 -1.0673776052 -0.98488939 -1.27000738 -1.17628373
[157,] -0.93430208 -0.9920355466 -1.28771487 -1.27000738 -1.34811007
[158,] -1.28723515 -1.0112532311 -1.28771487 -1.11817813 -1.60584958
[159,] -1.42840838 -0.9898517188 -1.28771487 -1.34592200 -1.43402324
[160,] -1.14606192 -0.9767487521 -1.28771487 -1.42183663 -1.51993641
[161,] -1.28723515 -1.0287238534 -0.98488939 -1.11817813 -1.00445739
[162,] -0.93430208 -0.9765303693 -1.28771487 -1.11817813 -1.64880616
[163,] -1.07547530 -0.9857024460 -1.28771487 -1.42183663 -1.34811007
[164,] -1.28723515 -1.0304709156 -1.28771487 -1.34592200 -1.60584958
[165,] -1.07547530 -1.0730555574 -0.98488939 -1.11817813 -1.69176275
[166,] -1.35782176 -1.0022995372 -1.28771487 -1.34592200 -1.39106665
annual_spend_in_USD
[1,] -1.0774232130
[2,] -0.9800244938
[3,] -1.0289422362
[4,] -1.0302525328
[5,] -0.9800244938
[6,] -1.0737107058
[7,] -1.0291606189
[8,] -1.0621364185
[9,] -1.0051385133
[10,] -1.0001157094
[11,] -0.9867943599
[12,] -0.9918171638
[13,] -0.9950929055
[14,] -1.0446657962
[15,] -1.0492518346
[16,] -0.9894149532
[17,] -1.0446657962
[18,] -1.0793886580
[19,] -1.0702165813
[20,] -0.9837370010
[21,] -0.9924723121
[22,] -1.0630099496
[23,] -1.0348385712
[24,] -0.9950929055
[25,] -0.9739097760
[26,] -1.0457577101
[27,] -1.0501253657
[28,] -1.0619180357
[29,] -0.9865759771
[30,] -0.9972767333
[31,] -1.0038282166
[32,] -0.9802428765
[33,] -1.0595158252
[34,] -1.0280687050
[35,] -1.0459760929
[36,] -1.0481599207
[37,] -0.9911620155
[38,] -1.0363672506
[39,] -1.0778599786
[40,] -0.9994605610
[41,] -0.9846105321
[42,] -0.9835186182
[43,] -1.0149657383
[44,] -0.9861392116
[45,] -0.9985870299
[46,] -1.0145289728
[47,] -1.0204253078
[48,] -1.0267584084
[49,] -1.0219539872
[50,] -1.0156208867
[51,] -1.0333098917
[52,] -1.0420452029
[53,] -1.0466312412
[54,] -1.0241378150
[55,] -1.0147473556
[56,] -1.0579871457
[57,] -1.0197701595
[58,] -1.0470680068
[59,] -1.0276319395
[60,] -1.0068855755
[61,] -1.0267584084
[62,] -0.9826450871
[63,] -1.0418268201
[64,] -1.0553665524
[65,] -0.9883230393
[66,] -1.0005524749
[67,] -0.9959664366
[68,] -1.0040465994
[69,] -1.0075407239
[70,] -1.0075407239
[71,] -1.0769864475
[72,] -1.0127819105
[73,] -1.0149657383
[74,] -1.0717452608
[75,] -1.0782967441
[76,] -0.9789325799
[77,] -1.0699981985
[78,] -1.0662856913
[79,] -1.0306892984
[80,] -0.9852656804
[81,] -1.0193333939
[82,] -1.0145289728
[83,] -0.9776222832
[84,] -1.0461944757
[85,] -1.0049201305
[86,] -1.0427003512
[87,] -1.0695614330
[88,] -0.9857024460
[89,] -0.9846105321
[90,] -0.9841737665
[91,] -1.0136554417
[92,] -1.0212988389
[93,] -1.0298157673
[94,] -0.9850472977
[95,] -1.0119083794
[96,] -0.9771855176
[97,] -1.0730555574
[98,] -1.0453209446
[99,] -1.0512172796
[100,] -0.9758752210
[101,] -1.0114716139
[102,] -1.0433554996
[103,] -1.0577687629
[104,] -1.0291606189
[105,] -1.0038282166
[106,] -1.0274135567
[107,] -1.0503437485
[108,] -1.0400797579
[109,] -1.0643202463
[110,] -1.0173679489
[111,] -0.9808980249
[112,] -0.9756568382
[113,] -1.0300341501
[114,] -1.0616996530
[115,] -1.0040465994
[116,] -0.9953112883
[117,] -1.0745842369
[118,] -1.0691246674
[119,] -1.0022995372
[120,] -1.0612628874
[121,] -0.9896333360
[122,] -0.9804612593
[123,] -0.9887598049
[124,] -1.0791702752
[125,] -1.0389878440
[126,] -1.0475047723
[127,] -1.0123451450
[128,] -0.9846105321
[129,] -1.0485966862
[130,] -1.0560217007
[131,] -1.0250113461
[132,] -1.0396429923
[133,] -1.0300341501
[134,] -1.0110348483
[135,] -1.0558033179
[136,] -1.0018627716
[137,] -0.9944377571
[138,] -0.9998973266
[139,] -1.0660673085
[140,] -0.9889781877
[141,] -1.0800438064
[142,] -1.0103797000
[143,] -1.0748026197
[144,] -1.0027363027
[145,] -1.0038282166
[146,] -1.0724004091
[147,] -0.9981502644
[148,] -1.0350569540
[149,] -1.0796070408
[150,] -1.0560217007
[151,] -1.0641018635
[152,] -1.0267584084
[153,] -0.9876678910
[154,] -1.0619180357
[155,] -1.0579871457
[156,] -1.0673776052
[157,] -0.9920355466
[158,] -1.0112532311
[159,] -0.9898517188
[160,] -0.9767487521
[161,] -1.0287238534
[162,] -0.9765303693
[163,] -0.9857024460
[164,] -1.0304709156
[165,] -1.0730555574
[166,] -1.0022995372
[ reached getOption("max.print") -- omitted 11834 rows ]
attr(,"scaled:center")
age annual_spend purchase_frequency website_engagement
newsletter_engagement
38.236250 5449.645500 5.252333 23.729417 60.383083
annual_spend_in_USD
6812.056875
attr(,"scaled:scale")
age annual_spend purchase_frequency website_engagement
newsletter_engagement
14.166992 4579.115653 3.302232 13.172693 23.279318
annual_spend_in_USD
5723.894567
> #Numbering Clusters
> set.seed(123)
> fviz_nbclust(VHCData_scale, kmeans, method = "wss") + ggtitle("Elbow Method to Determine
Optimal Clusters"fviz_nbclust(VHCData_scale, kmeans, method = "wss") + ggtitle("Elbow Method to
Determine Optimal Clusters")
Error: unexpected symbol in "fviz_nbclust(VHCData_scale, kmeans, method = "wss") +
ggtitle("Elbow Method to Determine Optimal Clusters"fviz_nbclust"
> fviz_nbclust(VHCData_scale, kmeans, method = "wss") + ggtitle("Elbow Method to Determine
Optimal Clusters")
> #Use-means with k (i.e. 3 clusters)
> set.seed(123)
> kmeans_result <- kmeans(VHCData_scale, centers = 3, nstart = 25)
> #Adding the cluster labels
> VData_clean$Cluster <- as.factor(kmeans_result$cluster)
> #Visualizing clusters
> fviz_cluster(kmeans_result, data = VHCData_scale) + ggtitle("Elbow Method to Determine Optimal
Clusters")
> csummary <- VData_clean %>% group_by(Cluster) %>%
+ summarise(across(everything(), mean))
> csummary
# A tibble: 3 × 7
Cluster age annual_spend purchase_frequency website_engagement newsletter_engagement
<fct> <dbl> <dbl> <dbl> <dbl> <dbl>
11 38.3 5448. 5.25 23.7 60.3
22 38.2 5448. 5.26 23.8 60.4
33 38.2 5459. 5.24 23.7 60.5
# ℹ 1 more variable: annual_spend_in_USD <dbl>
B. Characterization of Clusters
Using the analysis, three different clusters were formed. Each of them had unique consumer
characteristics.
Cluster 1: Consists of high-value clientele who engage with newsletters and have high spending
capacity.
Cluster 2: This cluster constitutes of those who have marginally better digital involvement such as on
both newsletters and website.
Cluster 3: Minimally engaged customers with typical spending and consumption patterns.
Q4.
Source Window:
#Loading packages
install.packages("C50")
library(C50)
install.packages("stringi")
summary(TechGadgets_Sales_Data)
#Converting to factors
TechGadgets_Sales_Data$product_type<-factor(TechGadgets_Sales_Data$product_type)
TechGadgets_Sales_Data$product_return<-factor(TechGadgets_Sales_Data$product_return)
#Again structure
str(TechGadgets_Sales_Data)
#Decision Tree model
install.packages("C50")
library(C50)
TD_model<-
C5.0(product_return~customer_income+product_type+purchase_amount+website_visits+product_re
views+warranty_period_months+warranty_period_years+customer_loyalty_score,data=TechGadget
s_Sales_Data)
summary(TD_model)
#plotting the tree
plot(TD_model)
#Reserving last 4000 observations as test dataset
tech_test<-tail(TechGadgets_Sales_Data,4000)
tech_train<-head(TechGadgets_Sales_Data,nrow(TechGadgets_Sales_Data)-4000)
#model on the training data
tech_train<-
C5.0(product_return~customer_income+product_type+purchase_amount+website_visits+product_re
views+warranty_period_months+warranty_period_years+customer_loyalty_score,data=TechGadget
s_Sales_Data)
#predictions on test dataset
prediction<-predict(tech_train,tech_test)
#Evaluate model
confusion_matrix <-table(tech_test$product_return,prediction)
print(confusion_matrix)
#Accuracy
Accuracy<-sum(diag(confusion_matrix))/sum(confusion_matrix)
print(Accuracy)
Console Window:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/xps/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/C50_0.1.8.zip'
Content type 'application/zip' length 343565 bytes (335 KB)
downloaded 335 KB
Restarting R session...
> install.packages("stringi")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and
install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/xps/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/xps/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/C50_0.1.8.zip'
Content type 'application/zip' length 343565 bytes (335 KB)
downloaded 335 KB
Call:
C5.0.formula(formula = product_return ~ customer_income + product_type + purchase_amount
+ website_visits + product_reviews + warranty_period_months + warranty_period_years
+ customer_loyalty_score, data = TechGadgets_Sales_Data)
Decision tree:
website_visits <= 15:
:...customer_income > 24516: 0 (9614/2.5)
: customer_income <= 24516:
: :...website_visits <= 13: 0 (331.4/1.4)
: website_visits > 13:
: :...customer_loyalty_score <= 7: 0 (54.1/1.1)
: customer_loyalty_score > 7:
: :...website_visits > 14: 1 (10/1)
: website_visits <= 14:
: :...customer_loyalty_score <= 8: 0 (6/1)
: customer_loyalty_score > 8: 1 (2)
website_visits > 15:
:...product_reviews <= 2: 1 (4169.5/1)
product_reviews > 2:
:...customer_income <= 34889:
:...website_visits <= 21:
: :...customer_loyalty_score <= 7:
: : :...customer_income > 26709:
: : : :...website_visits <= 20: 0 (366.3/0.2)
: : : : website_visits > 20:
: : : : :...customer_income > 29262: 0 (38)
: : : : customer_income <= 29262:
: : : : :...customer_loyalty_score <= 6: 0 (8)
: : : : customer_loyalty_score > 6: 1 (7)
: : : customer_income <= 26709:
: : : :...customer_loyalty_score > 6:
: : : :...website_visits <= 17:
: : : : :...customer_income > 23843: 0 (16)
: : : : : customer_income <= 23843:
: : : : : :...website_visits <= 16: 0 (4/1)
: : : : : website_visits > 16: 1 (4)
: : : : website_visits > 17:
: : : : :...website_visits > 18: 1 (19)
: : : : website_visits <= 18:
: : : : :...customer_income <= 25402: 1 (9)
: : : : customer_income > 25402: 0 (3)
: : : customer_loyalty_score <= 6:
: : : :...website_visits <= 18: 0 (43)
: : : website_visits > 18:
: : : :...customer_loyalty_score <= 5: 0 (14)
: : : customer_loyalty_score > 5:
: : : :...customer_income > 24019: 0 (11)
: : : customer_income <= 24019:
: : : :...website_visits > 19: 1 (8)
: : : website_visits <= 19: [S1]
: : customer_loyalty_score > 7:
: : :...website_visits <= 17:
: : :...customer_income <= 26034: 1 (8)
: : : customer_income > 26034: 0 (32/1)
: : website_visits > 17:
: : :...customer_income <= 28926: 1 (38)
: : customer_income > 28926:
: : :...customer_income > 33709: 0 (5)
: : customer_income <= 33709:
: : :...website_visits > 19: 1 (16)
: : website_visits <= 19:
: : :...customer_loyalty_score > 8: 1 (2)
: : customer_loyalty_score <= 8:
: : :...website_visits <= 18: 0 (7)
: : website_visits > 18:
: : :...customer_income <= 30705: 1 (4)
: : customer_income > 30705: 0 (2)
: website_visits > 21:
: :...customer_loyalty_score > 6:
: :...website_visits > 22: 1 (513.3/4.3)
: : website_visits <= 22:
: : :...customer_income <= 30880: 1 (44)
: : customer_income > 30880:
: : :...customer_loyalty_score <= 7: 0 (18)
: : customer_loyalty_score > 7: 1 (5)
: customer_loyalty_score <= 6:
: :...customer_income <= 29627:
: :...customer_loyalty_score > 5:
: : :...website_visits > 23: 1 (201)
: : : website_visits <= 23:
: : : :...customer_income <= 27124: 1 (26)
: : : customer_income > 27124: 0 (10)
: : customer_loyalty_score <= 5:
: : :...website_visits > 28: 1 (20)
: : website_visits <= 28:
: : :...customer_income > 26131: 0 (18/1)
: : customer_income <= 26131:
: : :...website_visits > 24: 1 (7)
: : website_visits <= 24:
: : :...customer_income <= 23266: 1 (2)
: : customer_income > 23266: 0 (4)
: customer_income > 29627:
: :...website_visits <= 26:
: :...website_visits <= 25: 0 (88.1/0.1)
: : website_visits > 25:
: : :...customer_income <= 30970: 1 (2)
: : customer_income > 30970: 0 (18)
: website_visits > 26:
: :...customer_loyalty_score <= 5:
: :...website_visits <= 32: 0 (15.1/0.1)
: : website_visits > 32: 1 (5/1)
: customer_loyalty_score > 5:
: :...website_visits > 28: 1 (61)
: website_visits <= 28:
: :...customer_income <= 32388: 1 (16)
: customer_income > 32388:
: :...website_visits <= 27: 0 (13)
: website_visits > 27:
: :...customer_income <= 33612: 1 (5)
: customer_income > 33612: 0 (8)
customer_income > 34889:
:...website_visits <= 26:
:...customer_loyalty_score <= 7: 0 (2177/2)
: customer_loyalty_score > 7:
: :...customer_income > 42222: 0 (347/2)
: customer_income <= 42222:
: :...website_visits <= 21:
: :...customer_loyalty_score <= 8: 0 (82)
: : customer_loyalty_score > 8:
: : :...website_visits <= 20: 0 (12)
: : website_visits > 20:
: : :...customer_income <= 38800: 1 (3)
: : customer_income > 38800: 0 (2)
: website_visits > 21:
: :...customer_loyalty_score > 8: 1 (15)
: customer_loyalty_score <= 8:
: :...website_visits > 25: 1 (8)
: website_visits <= 25:
: :...customer_income > 38649: 0 (16/2)
: customer_income <= 38649:
: :...website_visits <= 22: 0 (2)
: website_visits > 22: 1 (17/3)
website_visits > 26:
:...customer_income > 44225:
:...customer_loyalty_score <= 7:
: :...website_visits <= 33: 0 (505)
: : website_visits > 33:
: : :...customer_income > 48974: 0 (47)
: : customer_income <= 48974:
: : :...customer_loyalty_score <= 6: 0 (14)
: : customer_loyalty_score > 6: 1 (9)
: customer_loyalty_score > 7:
: :...customer_income <= 49279:
: :...customer_loyalty_score > 8: 1 (7)
: : customer_loyalty_score <= 8:
: : :...website_visits <= 28: 0 (6)
: : website_visits > 28: 1 (16/4)
: customer_income > 49279:
: :...website_visits <= 32: 0 (68/2)
: website_visits > 32:
: :...customer_income <= 54392: 1 (7)
: customer_income > 54392:
: :...website_visits <= 34: 0 (7)
: website_visits > 34:
: :...customer_income <= 61994: 1 (2)
: customer_income > 61994: 0 (4)
customer_income <= 44225:
:...customer_loyalty_score > 6:
:...customer_loyalty_score > 7: 1 (92)
: customer_loyalty_score <= 7:
: :...customer_income <= 38373: 1 (62/1)
: customer_income > 38373:
: :...website_visits <= 28: 0 (34)
: website_visits > 28:
: :...product_type = Accessories: 1 (0)
: product_type = Laptops:
: :...customer_income <= 43687: 1 (31)
: : customer_income > 43687: 0 (3/1)
: product_type = Smartphones:
: :...customer_income <= 41995: 1 (9/1)
: customer_income > 41995: 0 (12)
customer_loyalty_score <= 6:
:...website_visits <= 30: 0 (173/1)
website_visits > 30:
:...customer_loyalty_score <= 5: 0 (12)
customer_loyalty_score > 5:
:...customer_income <= 38537:
:...website_visits > 31: 1 (19)
: website_visits <= 31:
: :...customer_income <= 37273: 1 (2)
: customer_income > 37273: 0 (2)
customer_income > 38537:
:...website_visits <= 33: 0 (16)
website_visits > 33:
:...product_reviews > 3: 1 (3)
product_reviews <= 3:
:...customer_income <= 40682: 1 (2)
customer_income > 40682: 0 (4)
SubTree [S1]
Decision Tree
----------------
Size Errors
Attribute usage:
99.97%website_visits
78.95%customer_income
49.43%product_reviews
28.74%customer_loyalty_score
0.30% product_type
>
> plot(TD_model)
> #Reserving last 4000 observations as test dataset
> tech_test<-tail(TechGadgets_Sales_Data,4000)
> tech_train<-head(TechGadgets_Sales_Data,nrow(TechGadgets_Sales_Data)-4000)
> tech_train<-
C5.0(product_return~customer_income+product_type+purchase_amount+website_visits+product_re
views+warranty_period_months+warranty_period_years+customer_loyalty_score,data=TechGadget
s_Sales_Data)
>
> prediction<-predict(tech_train,tech_test)
>
> confusion_matrix <-table(tech_test$product_return,prediction)
> print(confusion_matrix)
prediction
0 1
0 2909 2
1 0 1089
> #Accuracy
> Accuracy<-sum(diag(confusion_matrix))/sum(confusion_matrix)
> print(Accuracy)
[1] 0.9995
> source("~/.active-rstudio-document")
Error in install.packages : Updating loaded packages
Error in install.packages : Updating loaded packages
'data.frame': 19805 obs. of 10 variables:
$ id : int 1 2 3 4 5 6 7 8 9 10 ...
$ customer_income : int 41499 52706 43570 38305 58658 28092 36049 66323 48183 34580 ...
$ product_type : Factor w/ 3 levels "Accessories",..: 2 3 2 3 2 3 1 3 1 3 ...
$ purchase_amount : num 1007 1317 394 1387 320 ...
$ website_visits : int 30 18 7 29 19 5 12 20 15 14 ...
$ product_reviews : int 2 2 2 4 2 2 2 1 2 4 ...
$ product_return : Factor w/ 2 levels "0","1": 2 2 1 2 2 1 1 2 1 1 ...
$ warranty_period_months: int 12 36 12 24 36 36 12 12 12 36 ...
$ warranty_period_years : int 1 3 1 2 3 3 1 1 1 3 ...
$ customer_loyalty_score: int 7 8 6 7 8 7 8 9 7 8 ...
Error in install.packages : Updating loaded packages
prediction
0 1
0 2909 2
1 0 1089
[1] 0.9995
Output
A. Application of Tree-Based
Several pre-processing steps were taken into consideration to make sure that the
dataset was appropriate for analysis:
1. Cleaning of Data
Some important parts of the data, like how much money customers earn
(customer_income) and whether they returned a product (product_return), were
incomplete. By filing in those missing pieces everything was ready to use.
2. Feature Engineering:
Analyzing the numbers in the data to make sure they weren’t too big or too small.
Since everything looked fine, nothing had to be changed.
4. Class Balance:
5. Dataset Preparation:
A Decision Tree model was chosen to accomplish the task. It is a flowchart, asking "yes" or "no"
questions in an effort to come up with the answer.
● Why this model? It's simple to understand, works okay even if some of the data is
missing, and doesn't get confused easily.
● An algorithm called C5.0 is used this keeps the tree from getting too complicated.
How It Worked
The model allowed to decide how to grow and shrink the tree, using default settings. It
also asked the best questions at each step to split the data (this is called entropy-based
splitting).
● The Decision Tree gave some interesting insights as to why customers return the
product.
● Website Visits: Customers with less website visits would typically not return the products.
● If they visited frequently, however, returns became more common.
● Purchasing power: Customers with less money were most likely to return.
● Product Reviews: Products that received poor reviews were returned more often.
● Customer Loyalty: Customers less loyal to the company returned more items.
● Accuracy: The model was right on the mark just about all the time, with an
accuracy rate of 99.95% on the training data.
● In fact, it made such few mistakes that it has an error rate of only 0.05%.
● CLVV: One of the rare models where actually the predictions got right, whether
products would be refunded or returned.
● Confusion Matrix:
● The confusion matrix demonstrates that the model accurately predicted the majority of
cases, with only a negligible number of misclassifications.
● It was found out that products less reviewed and hence often returned formed a problem.
● This requires a fine-tuning of the recommendation algorithm and products to have first
those that have high ratings and positive reviews. In doing so, the customer is likely to
receive the product he or she expects. Optimizing the filtering of products to better match
products with the specific needs and preferences of customers will reduce the returns
that are triggered by dissatisfaction.
● A higher percentage occurred among customers whose loyalty scores are in the lower
range.
● Implement both pre and post-purchase surveys to identify dissatisfaction as early in the
process as possible and offer focused programs or incentives toward loyalty, especially
special discounts and extra support on products that a customer is likely to return to
minimize returns and enhance long-term satisfaction.
● The warranty period has a moderate impact on the return behavior of customers.
● Tiered warranty options can be provided so that it creates a tendency in customers to
hold on to their product for longer periods. Return policies must undergo changes such
that impulsive returns are not incentivized without atrophying the customer's
satisfaction. This can be implemented through tight conditions on the return while
keeping it fair and transparent to the customer.
Final Evaluation
● The high accuracy and consistent performance for the training and test datasets
proves the effectiveness of the C5.0 model in predicting product returns.
● The results show the model’s effectiveness as a decision-support tool, hence suggesting
strategies to enhance the customer satisfaction and reduce return rates.
Conclusion
The C5.0 decision tree model showed credible factors driving product returns, hinting at
website_visits, custormer_income, and product_reviews being the most influential. Based on
this result, the changes proposed were refining of product suggestions, enhancing website
functionality and improving customer support initiatives. The model showed high accuracy in
both the training, as well as the test datasets, proving its reliability and effectiveness in helping
decision making.