Compa a i e S udy o Cus ome
Segmen a ion S a egies Based on
Business Analy ics
Documen :
Repo
Au ho : Da ide Aima
Di ec o /Co-di ec o : Vicen¸c Fe nandez Ala con
Deg ee:Mas e ’s Deg ee in Technology and Enginee ing
Managemen
Examina ion session: Au um
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Abs ac
This hesis explo es a compa a i e analysis o cus ome segmen a ion s a egies suppo ed by ad anced
analy ical me hodologies. I ocuses on wo ounda ional amewo ks: Recency, F equency, Mone a y
(RFM) and Cus ome Li e ime Value (CLV), which espec i ely cap u e sho - e m ansac ional
beha io s and long- e m economic con ibu ions. These me ics a e subsequen ly analyzed h ough i e
clus e ing algo i hms: K-Means,Hie a chical Clus e ing,DBSCAN,Gaussian Mix u e Models (GMM), and
Fuzzy C-Means.
The s udy u ilizes he UK E-Comme ce da a se om he UCI eposi o y, which unde goes me iculous
p ep ocessing and no maliza ion o ensu e obus and consis en inpu o he clus e ing models. The e alua ion
amewo k le e ages wo in e nal alida ion me ics— he Silhoue e Sco e and he Calinski–Ha abasz Index— o
p o ide complemen a y pe spec i es on local densi y sepa a ion and global a iance pa i ioning.
Expe imen al esul s e eal ha DBSCAN consis en ly ou pe o ms o he me hods in iden i ying dense
mic oclus e s, o en ep esen ing high- alue o niche cus ome s. In con as , K-Means and Hie a chical
Clus e ing exhibi s onge pe o mance in gene a ing b oade global pa i ions. While Fuzzy C-Means
achie es mode a e esul s by accommoda ing o e lapping segmen bounda ies h ough so membe ship,
GMM s uggles wi h he non-Gaussian cha ac e is ics o he RFM and CLV da ase s.
The indings unde sco e ha no single app oach uni e sally ou pe o ms he o he s. Ins ead, he selec ion
o me ics and clus e ing algo i hms should be s a egically aligned wi h business goals, such as iden i ying
anomalies o pe o ming la ge-scale segmen a ion. This s udy p o ides ac ionable insigh s o businesses
aiming o enhance ma ke ing s a egies, op imize esou ce alloca ion, and s eng hen cus ome ela ionship
managemen (CRM) h ough da a-d i en segmen a ion app oaches.
I
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Resumen
Es a esis explo a un an´alisis compa a i o de es a egias de segmen aci´on de clien es espaldado
po me odolog´ıas anal´ı icas a anzadas. Se cen a en dos ma cos undamen ales: Recencia, F ecuencia,
Valo Mone a io (RFM) yValo de Vida del Clien e (CLV), que cap u an espec i amen e los
compo amien os ansaccionales a co o plazo y las con ibuciones econ´omicas a la go plazo. Es os indicado es
se analizan pos e io men e median e cinco algo i mos de ag upamien o: K-Means,Clus e ing Je ´a quico,
DBSCAN,Modelos de Mezcla Gaussiana (GMM) yFuzzy C-Means.
El es udio u iliza el conjun o de da os de come cio elec ´onico del Reino Unido disponible en el eposi o io
UCI, que se some e a un me iculoso p ep ocesamien o y no malizaci´on pa a ga an iza en adas obus as y
consis en es pa a los modelos de ag upamien o. El ma co de e aluaci´on emplea dos m´e icas de alidaci´on
in e na—Silhoue e Sco e y el
´
Indice de Calinski–Ha abasz—que o ecen pe spec i as complemen a ias sob e
la sepa aci´on de densidades locales y la pa ici´on de a ianza global.
Los esul ados expe imen ales e elan que DBSCAN supe a cons an emen e a o os m´e odos al iden i ica
mic oclus e s densos, que a menudo ep esen an clien es de al o alo o nichos espec´ı icos. Po el con a io,
K-Means y el Clus e ing Je ´a quico mues an un mejo desempe˜no en la gene aci´on de pa iciones
globales m´as amplias. Mien as que Fuzzy C-Means log a esul ados mode ados al acomoda l´ımi es de
segmen os supe pues os median e asignaciones de memb es´ıa di usa, GMM iene di icul ades pa a maneja
las ca ac e ´ıs icas no gaussianas de los conjun os de da os RFM y CLV.
Los hallazgos des acan que ning´un en oque es uni e salmen e supe io . En cambio, la elecci´on de m´e icas y
algo i mos de ag upamien o debe alinea se es a ´egicamen e con los obje i os come ciales, como la de ecci´on
de anomal´ıas o la segmen aci´on a g an escala. Es e es udio p opo ciona ideas p ´ac icas pa a emp esas que
buscan mejo a sus es a egias de ma ke ing, op imiza la asignaci´on de ecu sos y o alece la ges i´on de
elaciones con clien es (CRM) a a ´es de en oques de segmen aci´on basados en da os.
II
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Con en s
1 In oduc ion 1
2 Li e a u e Re iew 3
2.1 RFM as a Baseline Segmen a ion Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Inco po a ing Cus ome Li e ime Value (CLV) . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Clus e ing Algo i hms o Segmen a ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3.1 K-MeansClus e ing ..................................... 5
2.3.2 Hie a chicalClus e ing.................................... 5
2.3.3 DBSCAN ........................................... 6
2.3.4 Gaussian Mix u e Models (GMM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.5 FuzzyC-Means........................................ 6
2.4 Le e aging CLV and RFM: Clus e ing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 Conclusion .............................................. 7
3 Me hodology 8
3.1 Da aCollec ion............................................ 9
3.1.1 P ep ocessing and Da a In eg i y: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2 Segmen a ionMe hodology ..................................... 10
3.2.1 RFMF amewo k....................................... 10
3.2.2 RFM Sco e Calcula ion and Segmen a ion . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.3 Cus ome Li e ime Value (CLV) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Clus e ingAlgo i hms ........................................ 14
3.3.1 K-meansClus e ing ..................................... 14
3.3.2 Clus e ing Algo i hms: Hie a chical Clus e ing . . . . . . . . . . . . . . . . . . . . . . 15
3.3.3 DBSCANClus e ing..................................... 16
3.3.4 Gaussian Mix u e Models (GMM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3.5 FuzzyC-meansClus e ing.................................. 19
3.4 Analy ical Tools and En i onmen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.5 ModelE alua ion........................................... 22
3.5.1 Silhoue eSco e ....................................... 22
III
CONTENTS CONTENTS
3.5.2 Calinski–Ha abaszIndex................................... 23
4 Resul s 25
4.1 RFM Segmen a ion & Clus e ing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1.1 RFM Segmen a ion Resul s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1.2 Clus e ing Resul s on RFM Segmen a ion . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 CLV Segmen a ion & Clus e ing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.2.1 CLVSegmen a ion...................................... 37
4.2.2 Clus e ing Resul s on CLV Segmen a ion . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.3 ModelsE alu a ion.......................................... 51
4.3.1 E alua iononRFMDa a .................................. 51
4.3.2 E alua iononCLVDa a .................................. 52
5 Conclusions 54
5.1 RFM analysis, clus e ing code and e alu a ion . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.1.1 RFM3D isualiza ion.................................... 73
5.2 CLV segmen a ion,clus e ing and model e alua ion . . . . . . . . . . . . . . . . . . . . . . . . 75
IV
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Lis o Figu es
3.1 The s uc u e o he me hodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.1 Dis ibu ion o RFM Segmen s Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2 Loga i hmic boxplo s o RFM indica o s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3 Elbowme hodg aph......................................... 28
4.4 KMeans2Dg aph.......................................... 29
4.5 k-NN Dis ance Plo o DBSCAN Pa ame e Selec ion (eps = 0.45). ............. 30
4.6 DBSCANClus e ing(RFM)..................................... 31
4.7 Hie a chicaldend og am....................................... 32
4.8 Clus e 5,6,7 zoomed in (le side o he p e ious dendog am) . . . . . . . . . . . . . . . . . . 33
4.9 Hie a chical Clus e ing on RFM Da a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.10 GMM clus e ing esul s (RFM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.11 Hea map o Fuzzy Membe ships (Sampled Da a) . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.12 Fuzzy C-Means Clus e ing (Ha d Assignmen s) . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.13 Elbow Me hod o K-Means (CLV Da a) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.14 K-Means Clus e ing on CLV Da a (2D P ojec ion) . . . . . . . . . . . . . . . . . . . . . . . . 39
4.15K-MeansRada Cha ........................................ 40
4.16 Hie a chical Clus e ing Dend og am (CLV Da a) . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.17 Hie a chical Clus e ing on CLV Da a (2D P ojec ion) . . . . . . . . . . . . . . . . . . . . . . 42
4.18hCRada Cha s........................................... 43
4.19 k-NN Dis ance Plo o DBSCAN Pa ame e s Selec ion (eps = 0.6).............. 44
4.20 DBSCAN Clus e ing on CLV Da a (2D P ojec ion) . . . . . . . . . . . . . . . . . . . . . . . . 45
4.21DBSCANRada Cha s ....................................... 46
4.22 GMM Clus e ing on CLV Da a (2D P ojec ion) . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.23GMMRada Cha .......................................... 48
4.24 Fuzzy C-Means Clus e ing on CLV Da a (Ha d Assignmen s) . . . . . . . . . . . . . . . . . . 50
4.25 CRada Cha s ........................................... 50
5.1 RFM K-Means Clus e ing (LOG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.2 RFM DBSCAN Clus e ing (LOG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
V
LIST OF FIGURES LIST OF FIGURES
5.3 RFMGMMClus e ing(LOG) ................................... 74
5.4 RFM Hie a chical Clus e ing (LOG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.5 RFMFuzzyClus e ing(LOG) ................................... 75
VI
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Lis o Tables
3.1 Cus ome Segmen a ion Based on RFM Sco es . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1 Segmen S a is ics o RFM Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2 Clus e S a is ics o K-Means Clus e ing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3 Clus e S a is ics o DBSCAN Clus e ing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4 Clus e S a is ics o Hie a chical Clus e ing. . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.5 Clus e S a is ics o GMM Clus e ing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.6 Clus e S a is ics o Fuzzy C-Means Clus e ing. . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.7 K-Means Clus e S a is ics o CLV-Based Analysis . . . . . . . . . . . . . . . . . . . . . . . . 39
4.8 Hie a chical Clus e ing (CLV) – Mean Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.9 Hie a chical Clus e ing (CLV) – S anda d De ia ions. . . . . . . . . . . . . . . . . . . . . . . 42
4.10 DBSCAN Clus e ing (CLV) – Mean Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.11 DBSCAN Clus e ing (CLV) – S anda d De ia ions. . . . . . . . . . . . . . . . . . . . . . . . . 45
4.12 GMM Clus e ing (CLV) – Mean Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.13 GMM Clus e ing (CLV) – S anda d De ia ions. . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.14 Fuzzy C-Means Clus e ing (CLV) – Mean Values. . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.15 Fuzzy C-Means Clus e ing (CLV) – S anda d De ia ions. . . . . . . . . . . . . . . . . . . . . 49
4.16 Silhoue e Sco es o RFM Clus e ing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.17 Calinski–Ha abasz Indices o RFM Clus e ing . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.18 Silhoue e Sco es o CLV Clus e ing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.19 Calinski–Ha abasz Indices o CLV Clus e ing . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
VII
2.3. CLUSTERING ALGORITHMS FOR SEGMENTATION CHAPTER 2. LITERATURE REVIEW
g ea e accu acy. By le e aging hese ools, companies can mo e beyond adi ional CLV calcula ions o
inco po a e a iables such as social in luence, channel p e e ences, and p oduc a ini y.
2.3 Clus e ing Algo i hms o Segmen a ion
While me ics like RFM and CLV de ine he dimensions o segmen a ion, clus e ing algo i hms g oup
cus ome s based on hese me ics. O e he pas decades, unsupe ised lea ning has become a p ac ical
solu ion o e ealing hidden pa e ns in da a wi hou p e-labeled ca ego ies.
2.3.1 K-Means Clus e ing
K-Means is among he mos widely used clus e ing algo i hms. I pa i ions da ase s in o clus e s by
minimizing in a-clus e a iance. M. K. Pakhi a e al.’s pape ”Validi y Index o C isp and Fuzzy Clus e s”
demons a es i s compu a ional e iciency and applicabili y o la ge da ase s [9]. Howe e , K-Means assumes
sphe ical clus e shapes and equi es p ede ining he numbe o clus e s (k), which may lead o subop imal
pe o mance i he ue da a s uc u e is non-sphe ical o unknown [10].
D. T. Pham e al. in ”Selec ion o K in K-Means Clus e ing” in oduced me hods o de e mining he op imal
numbe o clus e s, mi iga ing one o K-Means’ signi ican limi a ions [10]. The algo i hm’s simplici y makes
i ideal o ini ial explo a o y analysis in segmen a ion s udies.
K-Means is pa icula ly e ec i e o high- olume e ail da a, whe e compu a ional e iciency is pa amoun .
Howe e , i s uggles wi h da ase s con aining noise o clus e s o a ying densi y. To add ess hese limi a ions,
hyb id app oaches ha combine K-Means wi h densi y-based me hods like DBSCAN a e inc easingly being
explo ed.
2.3.2 Hie a chical Clus e ing
Hie a chical clus e ing builds a ee-like hie a chy o clus e s and is pa icula ly sui ed o da ase s
equi ing nes ed g oupings. A. D. Fallis’s a icle, ”Hie a chical Clus e ing App oaches o La ge Scale Da a,”
explo es i s u ili y in unco e ing mac o- and mic o-segmen a ion [11]. By employing linkage me hods such as
Wa d’s me hod, esea che s minimize wi hin-clus e a iance a each s ep [12]. Al hough compu a ionally
in ensi e, hie a chical clus e ing p o ides isual insigh s h ough dend og ams, aiding in de e mining op imal
cu poin s.
One o he p ima y ad an ages o hie a chical clus e ing is i s abili y o e eal mul i-le el segmen s uc u es.
Fo ins ance, in a e ail da ase , i can iden i y b oad cus ome ca ego ies such as ” equen buye s” and
”occasional shoppe s” while also unco e ing subg oups wi hin each ca ego y. Howe e , i s compu a ional
complexi y limi s i s scalabili y o e y la ge da ase s.
5
2.3. CLUSTERING ALGORITHMS FOR SEGMENTATION CHAPTER 2. LITERATURE REVIEW
2.3.3 DBSCAN
DBSCAN (Densi y-Based Spa ial Clus e ing o Applica ions wi h Noise) excels a iden i ying a bi a ily
shaped clus e s and isola ing ou lie s. M. Es e e al.’s ounda ional pape ”A Densi y-Based Algo i hm
o Disco e ing Clus e s in La ge Spa ial Da abases wi h Noise” in oduced his me hod, highligh ing i s
adap abili y [13]. DBSCAN does no equi e p ede ining he numbe o clus e s, elying ins ead on wo
pa ame e s: epsilon (
ϵ
) and he minimum numbe o poin s ( ex i MinP s) [14]. Schube e al. e isi ed
DBSCAN in hei pape ”DBSCAN Re isi ed, Re isi ed,” p o iding guidelines o pa ame e op imiza ion
and add essing challenges such as spa se da a dis ibu ions [14].
DBSCAN’s s eng h lies in i s abili y o handle noise and ou lie s, making i ideal o e ail da ase s wi h
i egula pu chasing beha io s. Fo example, i can isola e high- alue ou lie s such as co po a e clien s o
bulk buye s, which migh be misclassi ied in cen oid-based me hods. Howe e , i s pe o mance depends
hea ily on pa ame e uning, which equi es domain expe ise.
2.3.4 Gaussian Mix u e Models (GMM)
Gaussian Mix u e Models assume ha da a a ises om a mix u e o Gaussian dis ibu ions. J. Han
e al. in ”Da a Mining: Concep s and Techniques” de ailed GMM’s lexibili y, which allows clus e s o
ake on a ious shapes [15]. GMM uses he Expec a ion-Maximiza ion algo i hm o i e a i ely e ine clus e
pa ame e s, making i sui able o da ase s wi h o e lapping o non-sphe ical dis ibu ions. Howe e , i s
eliance on Gaussian assump ions may limi i s e ec i eness o highly skewed o mul i-modal da a.
GMM is pa icula ly sui ed o da ase s whe e clus e s exhibi signi ican o e lap, such as cus ome g oups
wi h simila spending pa e ns bu di e en p oduc p e e ences. I s p obabilis ic amewo k allows o so
clus e ing, assigning each cus ome a likelihood o belonging o mul iple clus e s.
2.3.5 Fuzzy C-Means
Fuzzy C-Means ex ends adi ional clus e ing by assigning membe ship deg ees o each clus e , accom-
moda ing blu y segmen bounda ies. J. C. Bezdek’s book ”Pa e n Recogni ion wi h Fuzzy Objec i e
Func ion Algo i hms” in oduced his concep , emphasizing i s ele ance o da ase s whe e cus ome s exhibi
o e lapping beha io s [16]. While ad an ageous o cap u ing sub le di e ences, Fuzzy C-Means equi es
ca e ul uning o pa ame e s like he uzzi ie , which can complica e i s applica ion.
The lexibili y o Fuzzy C-Means makes i pa icula ly aluable o cus ome segmen a ion in indus ies
wi h di e se p oduc o e ings. Fo ins ance, in e-comme ce, cus ome s migh exhibi cha ac e is ics o bo h
”ba gain hun e s” and ”p emium buye s.” By allowing pa ial membe ship, Fuzzy C-Means p o ides insigh s
in o hyb id cus ome p o iles, enabling mo e pe sonalized ma ke ing s a egies.
6
2.4. LEVERAGING CLV AND RFM: CLUSTERING CHAPTER 2. LITERATURE REVIEW
2.4 Le e aging CLV and RFM: Clus e ing
Empi ical s udies ad oca e combining CLV me ics wi h ad anced clus e ing algo i hms o a mul idimen-
sional unde s anding o cus ome beha io . Khaj and e al.’s s udy demons a ed how CLV-weigh ed RFM
sco es enhance segmen a ion by iden i ying high-li e ime- alue cus ome s wi h spo adic ac i i y [4]. This
aligns wi h Gup a e al.’s concep o pe sis ence models, whe e po en ial u u e alue guides ma ke ing
s a egies [6].
DBSCAN’s abili y o isola e ou lie s has p o en e ec i e o iden i ying “sleepe s” o occasional high spende s
who migh o he wise be o e looked by cen oid-based me hods [5]. Real- ime clus e ing app oaches a e
gaining ac ion, adap ing dynamically o upda ed ansac ions, e u ns, o seasonal a ia ions [15].
In eg a ing CLV and RFM wi h clus e ing algo i hms p o ides a holis ic iew o cus ome beha io . Fo
example, a company migh use Fuzzy C-Means o iden i y hyb id p o iles, combining his insigh wi h CLV
me ics o p io i ize high- alue segmen s. Simila ly, DBSCAN can unco e hidden pa e ns in noisy da ase s,
while GMM o e s p obabilis ic insigh s in o o e lapping cus ome beha io s.
2.5 Conclusion
The li e a u e illus a es a clea p og ession in segmen a ion s a egies, om simple RFM cons uc s o
complex CLV-enhanced models and ad anced clus e ing algo i hms. While RFM e ains i s appeal o
simplici y, i s in eg a ion wi h CLV enables a deepe di e en ia ion o cus ome s, iden i ying no only equen
spende s bu also hose wi h signi ican u u e alue. The choice o clus e ing algo i hm is con ex -dependen :
K-Means o scalabili y, Hie a chical o mul i-le el g ouping, DBSCAN o ou lie de ec ion, GMM o
o e lapping clus e s, and Fuzzy C-Means o accommoda ing blu ed segmen bounda ies. By s a egically
combining hese me hodologies, p ac i ione s can de i e segmen s ha a e bo h ac ionable o immedia e
use and p edic i e o u u e beha io .
7
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Chap e 3
Me hodology
The me hodology o he hesis ollows a s uc u ed, sequen ial app oach o p ocess and analyze he da ase
o cus ome segmen a ion using ad anced clus e ing echniques [1]. Below is an ou line o he me hodology
as illus a ed in he igu e 3.1
•Da ase :
–
The analysis begins wi h a da ase sou ced om he UCI Machine Lea ning Reposi o y, con aining
ansac ional da a om an online e aile .
•P ep ocessing:
–The da ase unde goes p ep ocessing o clean and e ine he da a.
•Segmen a ion:
–The e ined da a is segmen ed using wo app oaches:
∗
RFM (Recency, F equency, Mone a y) segmen a ion: Assigning sco es o cus ome s
based on hei pu chase beha io [3].
Figu e 3.1: The s uc u e o he me hodology
8
3.1. DATA COLLECTION CHAPTER 3. METHODOLOGY
∗
CLV (Cus ome Li e ime Value) calcula ion: Es ima ing he long- e m alue o each
cus ome [4].
•Clus e ing Models:
–Bo h RFM and CLV segmen a ions a e independen ly subjec ed o clus e ing using i e models
1. K-means
2. Hie a chical clus e ing
3. DBSCAN
4. Gaussian Mix u e Models (GMM)
5. Fuzzy C-means
•Model E alua ion:
–Each clus e ing solu ion is e alua ed using wo me ics:
∗Silhoue e Sco e: Measu es clus e cohesion and sepa a ion.
∗
Calinski-Ha abasz Index: Assesses he a io o be ween-clus e o wi hin-clus e a iance
[9].
–
The e alua ion compa es he pe o mance o clus e ing models o bo h RFM and CLV segmen a-
ions.
3.1 Da a Collec ion
The da ase used in his hesis was sou ced om he UCI Machine Lea ning Reposi o y. I consis s o
ansac ional eco ds om a UK-based, non-s o e online e aile , spanning om Decembe 1, 2010, o
Decembe 9, 2011. This pe iod includes he c i ical holiday shopping season, p o iding aluable insigh s in o
consume beha io du ing peak e ail ac i i y.
Da ase Desc ip ion: The da ase includes 541,909 ansac ions, de ailed ac oss eigh a ibu es ha o e
bo h mul i a ia e and ime-se ies insigh s in o e ail ope a ions and cus ome demog aphics:
•In oiceNo: T ansac ion iden i ie ; i p e ixed wi h ’C’, indica es a cancella ion.
•S ockCode: Unique p oduc code.
•Desc ip ion: Tex desc ip ion o he p oduc .
•Quan i y: Numbe o uni s pu chased in each ansac ion.
•In oiceDa e: Times amp o each ansac ion (e.g., ”12/1/2010 8:26”).
•Uni P ice: P ice pe uni o he p oduc .
•Cus ome ID: Unique iden i ie o each cus ome .
9
3.2. SEGMENTATION METHODOLOGY CHAPTER 3. METHODOLOGY
•Coun y: Coun y o he cus ome .
3.1.1 P ep ocessing and Da a In eg i y:
C i ical p ep ocessing s eps we e unde aken o ensu e he da a’s eliabili y o subsequen analysis:
•
Da a Cleaning: Duplica e eco ds we e emo ed o ensu e da a uniqueness. T ansac ions iden i ied as
cancella ions, h ough In oiceNo p e ixes, we e seg ega ed o p e en dis o ion o pu chasing pa e ns.
•
Da e Pa sing: The ’In oiceDa e’ ield was con e ed om s ing o ma in o a da e- ime objec o
acili a e ime-se ies analyses.
•
E o Handling: En ies wi hou Cus ome ID o wi h un ealis ic ansac ion alues (e.g., nega i e
p ices o quan i ies) we e sc u inized and handled app op ia ely.
Finally, a column o he ”To alP ice” was added o he da ase . This was calcula ed by mul iplying he
quan i y o each i em by i s uni p ice. These s ep was impo an o ob ain he Mone a y Value o each
ansac ion.
Pos -p ep ocessing, he da ase was s eamlined o 392692 eco ds dis ibu ed ac oss nine columns ( he
o iginal eigh plus he new one o ”To alP ice”). This e ined da ase was ee om he common da a
issues ha could unde mine he alidi y o he analysis, hus se ing a s ong ounda ion o he subsequen
segmen a ion.
3.2 Segmen a ion Me hodology
3.2.1 RFM F amewo k
The Recency, F equency, Mone a y (RFM) model is a cus ome segmen a ion echnique widely used in
da abase ma ke ing and e ail analy ics. This model e alua es cus ome s by assigning a sco e based on h ee
speci ic c i e ia:
•
Recency (R): Recency measu es how ecen ly a cus ome made a pu chase. A lowe ecency alue
indica es ha he cus ome bough om he s o e o business mo e ecen ly, which sugges s highe
engagemen and likelihood o epea pu chases. Recency is calcula ed by sub ac ing he da e o a
cus ome ’s las pu chase om he cu en da e, o en exp essed in days:
R= Cu en Da e −Las Pu chase Da e
•
F equency (F): F equency indica es how o en a cus ome makes a pu chase wi hin a gi en ime ame.
Businesses o en ack he o al numbe o ansac ions each cus ome has comple ed du ing a speci ic
pe iod o de e mine loyal y and engagemen le els. F equen in e ac ions a e ypically a sign o a
10
3.2. SEGMENTATION METHODOLOGY CHAPTER 3. METHODOLOGY
cus ome ’s us and sa is ac ion wi h he b and:
F= To al numbe o ansac ions
•
Mone a y (M): This me ic assesses he o al amoun o money a cus ome has spen o e ime.
Highe mone a y alues a e an indica o o highe cus ome alue o he o ganiza ion. Companies
o en use his dimension o iden i y hei mos aluable cus ome s o ’high spende s’ who a e likely o
con ibu e a signi ican po ion o e enue:
M= To alP ice = Uni P ice ×Quan i y
Applying he RFM model allows businesses o de elop di e en ia ed ma ke ing s a egies and pe sonalize
communica ions. This app oach no only enhances cus ome sa is ac ion bu also op imizes ma ke ing e o s
by ocusing on he mos luc a i e segmen s.
3.2.2 RFM Sco e Calcula ion and Segmen a ion
To segmen he cus ome da ase e ec i ely, each RFM me ic was quan i ied and sco ed based on quin iles.
Each cus ome ecei ed a sco e om 1 o 5 o each me ic, whe e a sco e o 5 ep esen s he op 20% o
beha io (e.g., mos ecen pu chases, highes equency, and highes spending).
•
Cus ome s we e anked based on each me ic, and he anks we e hen di ided in o i e equal g oups o
quin iles. The quin iles helped in assigning a scaled sco e o each RFM pa ame e .
•
Recency sco es we e in e ed, whe e cus ome s who pu chased mo e ecen ly sco ed highe (i.e., a
cus ome wi h he mos ecen pu chase ge s a sco e o 5).
•F equency and Mone a y alues we e sco ed no mally, whe e highe alues ecei ed highe sco es.
This me hod allows o he iden i ica ion o dis inc g oups based on hei ansac ional beha io , enabling
a ge ed ma ke ing s a egies.
De ining Cus ome Segmen s
Based on he calcula ed RFM sco es, cus ome s we e classi ied in o six segmen s. This classi ica ion helps in
ailo ing ma ke ing e o s acco ding o he speci ic cha ac e is ics o each segmen :
So based on he p e ious able we go he ollowing segmen
•
Whales: These a e op- ie cus ome s wi h ecen pu chases, high ansac ion equency, and signi ican
spending, necessi a ing ocused e en ion s a egies and exclusi e p omo ions.
•
Ac i e S a s: Simila o Whales in beha io bu sligh ly less in ense in hei in e ac ions, hey a e
pi o al due o hei conside able expendi u e and equen pu chases.
11
3.2. SEGMENTATION METHODOLOGY CHAPTER 3. METHODOLOGY
Table 3.1: Cus ome Segmen a ion Based on RFM Sco es
R sco e F sco e M sco e Segmen
5 5 5 Whales
≥4≥3≥4 Ac i e S a s
≥4≥4≤3 Loyal Regula s
≤3≥3≥4 Sleeping Gian s
≥4≤3≤5 New & Occasional Buye s
O he cases Los Clien s
•
Loyal Regula s: Regula and ecen pu chase s wi h mode a e spending, o ming a s able e enue
base and can be a ge ed wi h p omo ions o inc ease spending.
•
Sleeping Gian s: P e iously high- alue cus ome s now inac i e, iden i ied as po en ial sou ces o
e enue i e-engaged e ec i ely.
•
New & Occasional Buye s: Cus ome s wi h ecen bu in equen pu chases, holding po en ial o
de elopmen in o egula buye s h ough e ec i e e en ion s a egies.
•
Los Clien s: The leas engaged and his o ically low-spending, o en no p io i ized unless speci ic
e-engagemen s a egies a e easible.
3.2.3 Cus ome Li e ime Value (CLV)
The concep o Cus ome Li e ime Value (CLV) is ano he way o segmen ing cus ome s o unde s and he
long- e m alue o a cus ome o a business. I helps in de e mining how much a company should in es in
main aining ela ionships wi h exis ing cus ome s and in acqui ing new ones [6].
CLV ep esen s he o al e enue ha a company can expec om a cus ome h oughou hei business
ela ionship. The alue is calcula ed based on he p o i ma gin o he ansac ions, ac o ing in he e en ion
a e and discoun a e o accoun o he ime alue o money. Unde s anding he CLV helps businesses ocus
hei ma ke ing e o s on cus ome s who a e likely o deli e he highes li e ime alue.
Me hodology o Calcula ing CLV
The calcula ion o CLV in his s udy ollows a de ined se ies o s eps, using he cleaned and p ep ocessed
da ase desc ibed in p e ious chap e s. He e, we elabo a e on each s ep in ol ed in he calcula ion:
Calcula ion o Key Me ics Th ee p ima y me ics a e calcula ed o each cus ome :
•
To al Re enue: This is he sum o he
To alP ice
o all ansac ions pe cus ome , gi ing a
cumula i e alue o how much he cus ome has spen . I is a di ec mul iplica ion o he
Quan i y
and Uni P ice o each i em pu chased, summed ac oss all ansac ions.
12
3.2. SEGMENTATION METHODOLOGY CHAPTER 3. METHODOLOGY
•
F equency: This me ic measu es he numbe o dis inc in oices pe cus ome , indica ing how o en
he cus ome engages in ansac ions. I se es as an index o cus ome loyal y and pu chasing equency.
•
A e age T ansac ion Value: Calcula ed as he a e age
To alP ice
pe ansac ion o each cus ome .
This me ic p o ides insigh in o he spending beha io o he cus ome pe ansac ion.
Li e ime Calcula ion The li espan o he cus ome ela ionship is compu ed by de e mining he numbe
o days be ween he i s and las pu chase da es. This me ic p o ides a empo al dimension o he mone a y
and equency alues, o e ing a mo e comp ehensi e iew o he cus ome ’s engagemen o e ime.
Compu a ion o CLV The CLV is hen calcula ed using he o mula:
CLV = F equency ×A e age T ansac ion Value ×Expec ed Li espan
Whe e:
•F equency is he numbe o ansac ions (as calcula ed ea lie ).
•A e age T ansac ion Value is he mean spending pe ansac ion.
•
Expec ed Li espan is an es ima ed du a ion o he cus ome ela ionship in mon hs. This du a ion
can be adjus ed based on his o ical da a o indus y a e ages.
This o mula in eg a es bo h beha io al (F equency, A e age T ansac ion Value) and empo al (Expec ed
Li espan) aspec s o p o ide a comp ehensi e es ima e o he cus ome ’s o al po en ial alue o he business.
Role o CLV in Cus ome Segmen a ion
A e calcula ing he CLV, his me ic becomes a co ne s one o u he segmen a ion analysis. I allows
businesses o ca ego ize cus ome s in o segmen s based on hei alue, enabling mo e a ge ed and e ec i e
ma ke ing s a egies. High-CLV cus ome s can be iden i ied o p emium se ices, while s a egies o
imp o ing he CLV o lowe -sco ing cus ome s can be de eloped.
In eg a ing CLV wi h he p e iously discussed RFM segmen a ion p o ides a obus amewo k o un-
de s anding cus ome beha io in a mul idimensional space, whe e each me ic o e s unique insigh s in o
cus ome loyal y, spending, and engagemen .
The calcula ed CLV no only in o ms abou he pas and p esen alue o he cus ome s bu also helps
p edic u u e in e ac ions and p o i abili y, guiding s a egic decisions in cus ome ela ionship managemen
and ma ke ing. This sys ema ic app oach o calcula ing and u ilizing CLV ensu es ha he segmen a ion
and a ge ing a e g ounded in economic eali y, aiming o maximize he e u n on in es men in cus ome
ela ionships.
13
3.3. CLUSTERING ALGORITHMS CHAPTER 3. METHODOLOGY
3.3 Clus e ing Algo i hms
3.3.1 K-means Clus e ing
Clus e ing o K-means is an in luen ial unsupe ised machine lea ning echnique ha is used o g oup simila
da a poin s in o a p ede e mined numbe o clus e s, deno ed as k. This me hod is pa icula ly e ec i e in
cus ome segmen a ion, aiding businesses in disce ning he s uc u e wi hin hei cus ome base and enabling
a ge ed ma ke ing s a egies [10].
Algo i hm O e iew
The K-means algo i hm o ganizes
n
obse a ions in o
k
clus e s whe e each obse a ion belongs o he clus e
wi h he closes mean, se ing as he clus e ’s p o o ype. Ini ially,
k
cen oids a e selec ed andomly om he
da ase . Subsequen ly, each da a poin is assigned o he nea es cen oid based on he Euclidean dis ance,
and he cen oids a e ecalcula ed as he mean o all poin s in he clus e . This p ocess i e a es; poin s a e
eassigned and cen oids upda ed un il he cen oids s abilize and exhibi minimal o no mo emen , indica ing
con e gence.
Ma hema ical Fo mula ion
The goal o K-means is o minimize he wi hin-clus e sum o squa es (WCSS), which ep esen s he sum o
squa ed dis ances be ween each poin and i s espec i e cen oid, ma hema ically exp essed as:
Minimize WCSS =
k
X
i=1 X
x∈Si
∥x−µi∥2
whe e µideno es he mean o poin s in Si, and kis he numbe o clus e s.
Choosing he Numbe o Clus e s
The ’Elbow Me hod’ is commonly employed o de e mine he op imal numbe o clus e s [10]. I in ol es
execu ing he K-means algo i hm ac oss a ange o k alues and plo ing he WCSS o each. The op imal k
ypically co esponds o he poin whe e he WCSS cu e le els o , c ea ing an elbow shape. This me hod
is use ul because i p o ides a isual cue o he poin a which inc easing he numbe o clus e s ceases o
esul in signi ican ly lowe wi hin-clus e a ia ion. The Elbow Me hod is pa icula ly e ec i e when he
dec ease in WCSS becomes negligible, sugges ing ha adding mo e clus e s migh lead o o e i ing wi hou
subs an ial gains in cap u ing dis inc g oupings.
Algo i hm S eps
1. Ini ializa ion: Selec kini ial cen oids andomly om he da a poin s.
2. Assignmen : Assign each da a poin o he nea es cen oid, de e mined by he Euclidean dis ance.
3. Upda e: Recalcula e cen oids as he mean o he poin s in each clus e .
14
3.4. ANALYTICAL TOOLS AND ENVIRONMENT CHAPTER 3. METHODOLOGY
ou . In ou con ex , we chose
m
= 2 because i o e s a easonable ade-o : we wan ed o allow o pa ial
membe ship in mul iple segmen s bu s ill e ain ela i ely dis inc clus e cen e s o clea e in e p e a ion.
In e p e ing Resul s
In uzzy clus e ing, each cus ome (o da a poin ) is assigned a ec o o membe ship alues, indica ing i s
deg ee o belonging o each clus e . P ac ical app oaches include:
•
Using Fuzzy Membe ships Di ec ly: Analyze he so membe ships o explo e nuanced o hyb id
cus ome p o iles. This can e eal sub le o e laps whe e cus ome s exhibi cha ac e is ics o mul iple
segmen s.
•
Ha d Clus e ing Con e sion: Fo simple compa ison wi h o he clus e ing app oaches (e.g.,
k
-
means), one may con e uzzy membe ships o a single clus e label by assigning each poin o he
clus e wi h he highes membe ship. While his loses some g anula i y, i simpli ies subsequen analyses
and isualiza ions.
By accommoda ing pa ial membe ships, FCM en iches he unde s anding o cus ome beha io s, iden i ying
o e lapping endencies ha migh no be cap u ed by s ic ly pa i ioning me hods. This can be pa icula ly
bene icial when pe o ming RFM segmen a ion, whe e spending and pu chase equency o en s addle
bounda ies, sugges ing ha cus ome s na u ally i in o mo e han one a che ypal clus e .
Implemen a ion in R
The
e1071
package in R implemen s Fuzzy C-means clus e ing h ough he
cmeans()
unc ion, allowing
use s o speci y pa ame e s such as he uzzi ica ion exponen (
m
), he numbe o clus e cen e s (
cen e s
),
maximum i e a ions (
i e .max
), and con e gence h esholds. This unc ion au oma ically compu es bo h
he cen oids and he membe ship ma ix, whe e each da a poin e ains pa ial membe ship ac oss mul iple
clus e s.
3.4 Analy ical Tools and En i onmen
The analysis p esen ed in his hesis was conduc ed using R, a language and en i onmen o s a is ical
compu ing and g aphics. The speci ic e sion used was R e sion 4.3.1 (2023-06-16 uc ), unning
on a Windows 11 pla o m wi h an x86 64-w64-mingw32/x64 (64-bi ) a chi ec u e. The analysis
was pe o med using RS udio, an in eg a ed de elopmen en i onmen o R, e sion 2024.09.1+394
”C anbe y Hibiscus”.
Lib a ies and Packages
Se e al addi ional packages we e employed o suppo he analysis, each chosen o i s speci ic ea u es ha
aid in da a manipula ion, isualiza ion, and clus e ing analysis. The URLs o hei Comp ehensi e R A chi e
Ne wo k (CRAN) pages.
21
3.5. MODEL EVALUATION CHAPTER 3. METHODOLOGY
•
dply ( e sion 1.1.3): A g amma o da a manipula ion, p o iding a consis en se o e bs o ackling
common da a-handling challenges. URL: h ps://CRAN.R-p ojec .o g/package=dply
•
lub ida e ( e sion 1.9.2): Simpli ies da e and ime pa sing and manipula ion in R, o e ing in ui i e
handling o ime-se ies da a. URL: h ps://CRAN.R-p ojec .o g/package=lub ida e
•
ggplo 2 ( e sion 3.5.1): A sys em o decla a i ely c ea ing g aphics, based on The G amma o
G aphics, o e ing lexible and laye ed isualiza ions. URL:
h ps://CRAN.R-p ojec .o g/package=
ggplo 2
•
plo ly ( e sion 4.10.4): An in e ace o he Plo ly Ja aSc ip g aphing lib a y, enabling in e ac i e,
web-based da a isualiza ions. URL: h ps://CRAN.R-p ojec .o g/package=plo ly
•
clus e ( e sion 2.1.4): Implemen s me hods o clus e analysis, including agglome a i e hie a chi-
cal clus e ing, essen ial o cus ome segmen a ion. URL:
h ps://CRAN.R-p ojec .o g/package=
clus e
•
dbscan ( e sion 1.2-0): A as eimplemen a ion o he DBSCAN (Densi y-Based Spa ial Clus e ing o
Applica ions wi h Noise) clus e ing algo i hm. URL:
h ps://CRAN.R-p ojec .o g/package=dbscan
•
mclus ( e sion 6.1.1): P o ides model-based clus e ing using ini e Gaussian mix u e models, wi h
au oma ic model selec ion based on BIC. URL: h ps://CRAN.R-p ojec .o g/package=mclus
•
e1071 ( e sion 1.7-13): Includes uzzy clus e ing (
cmeans
) and addi ional machine lea ning ools such
as Suppo Vec o Machines. URL: h ps://CRAN.R-p ojec .o g/package=e1071
•
eshape2 ( e sion 1.4.4): Facili a es eshaping and mel ing o da a ames, aiding in da a ans o ma ion
p io o analysis o isualiza ion. URL: h ps://CRAN.R-p ojec .o g/package= eshape2
•
pc ( e sion 2.2-13): Con ains clus e ing me hods and alida ion ools, complemen ing DBSCAN wi h
diagnos ic and plo ing unc ions. URL: h ps://CRAN.R-p ojec .o g/package= pc
These ools and lib a ies we e in eg al o he execu ion o he analysis, enabling da a manipula ion, clus e ing,
and isualiza ion. Thei explici inclusion, alongside e sion numbe s and URLs, ensu es he anspa ency
and ep oducibili y o he esea ch.
3.5 Model E alua ion
The clus e ing solu ions o bo h he RFM and CLV da ase s we e e alua ed using wo in e nal alida ion
me ics: he Silhoue e Sco e and he Calinski–Ha abasz Index (CH). These me ics we e chosen o
hei abili y o measu e bo h clus e compac ness and sepa a ion, p o iding a obus e alua ion amewo k.
3.5.1 Silhoue e Sco e
The Silhoue e Sco e e alua es he quali y o a clus e ing solu ion by assessing how simila each da a poin
is o poin s in i s own clus e (cohesion) ela i e o poin s in he nea es o he clus e (sepa a ion). This
22
3.5. MODEL EVALUATION CHAPTER 3. METHODOLOGY
me ic is pa icula ly use ul o unde s anding he in e nal s uc u e o he clus e s and iden i ying po en ial
misclassi ica ions. [15].
Ma hema ical De ini ion: Fo a gi en poin i, he Silhoue e Sco e S(i) is de ined as:
S(i) = b(i)−a(i)
max(a(i), b(i)),
whe e:
•a(i): The a e age dis ance be ween iand all o he poin s in he same clus e (in a-clus e dis ance).
•b
(
i
): The a e age dis ance be ween
i
and all poin s in he nea es neighbo ing clus e (in e -clus e
dis ance).
The o e all Silhoue e Sco e is compu ed as he mean o S(i) o all poin s:
S=1
n
n
X
i=1
S(i),
whe e nis he o al numbe o poin s.
In e p e a ion:
•S(i)≈1: The poin is well-clus e ed.
•S(i)≈0: The poin lies on he bounda y be ween clus e s.
•S(i)<0: The poin may be misclassi ied.
Special Handling:
•
DBSCAN: Poin s labeled as noise (
−
1) we e excluded om he calcula ion, as hey do no belong o
any alid clus e .
•
Fuzzy C-means: The uzzy membe ships we e con e ed o ha d clus e assignmen s by assigning
each poin o he clus e whe e i s membe ship alue was highes (a g max).
3.5.2 Calinski–Ha abasz Index
The Calinski–Ha abasz Index e alua es clus e ing quali y by measu ing he a io o he be ween-clus e
a iance o he wi hin-clus e a iance. I ewa ds clus e ing solu ions wi h well-sepa a ed and compac
clus e s.
Ma hema ical De ini ion: The CH index is de ined as:
CH =Be ween-clus e a iance/(k−1)
Wi hin-clus e a iance/(n−k),
whe e:
23
3.5. MODEL EVALUATION CHAPTER 3. METHODOLOGY
•k: The numbe o clus e s.
•n: The o al numbe o poin s.
•Be ween-clus e a iance:
B=
k
X
j=1
nj∥µj−µ∥2,
whe e
nj
is he size o clus e
j
,
µj
is he cen oid o clus e
j
, and
µ
is he o e all mean o he da ase .
•Wi hin-clus e a iance:
W=
k
X
j=1 X
x∈Cj
∥x−µj∥2,
whe e Cjdeno es he poin s in clus e j.
In e p e a ion:
•
Highe CH alues indica e be e clus e ing solu ions, wi h mo e compac clus e s and g ea e sepa a ion
be ween clus e s.
Special Handling:
•
DBSCAN: I he algo i hm iden i ies only one clus e o assigns all poin s as noise, he CH index is
unde ined.
•
Fuzzy C-means: Simila o he Silhoue e Sco e, he uzzy membe ships we e con e ed o ha d
assignmen s be o e calcula ing he CH index.
24
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Chap e 4
Resul s
4.1 RFM Segmen a ion & Clus e ing
This subsec ion p esen s he indings o he RFM segmen a ion and subsequen clus e ing.
4.1.1 RFM Segmen a ion Resul s
Segmen Dis ibu ion
The segmen a ion p ocess ca ego ized he cus ome base in o six dis inc g oups: Whales, Ac i e S a s,
Loyal Regula s, New & Occasional Buye s, Sleeping Gian s, and Los Clien s. These segmen s
we e de ined based on h esholds o ecency, equency, and mone a y alue de i ed om he RFM sco es.
The pe cen age dis ibu ion o cus ome s ac oss hese segmen s is summa ized in igu e 4.1. The esul s
e eal signi ican dispa i ies in cus ome beha io :
•
Los Clien s o m he la ges segmen , comp ising 47.12% o he o al cus ome base. This g oup
demons a es he longes ecency and he lowes equency and mone a y me ics, indica ing minimal
ecen engagemen and low e enue con ibu ions.
•
Ac i e S a s ep esen 15.65% o he cus ome s, showing mode a e ecency and equency coupled
wi h highe mone a y alue, making hem a aluable segmen o engagemen .
•
Whales comp ise 8.02% o cus ome s bu a e dis inguished by hei high equency (18.2 ansac ions)
and mone a y alue (€11,222 on a e age), ep esen ing he mos aluable segmen .
•
Smalle g oups like Loyal Regula s (4.03%) and New & Occasional Buye s (12.26%) highligh
s able o eme ging pu chasing pa e ns.
•
Sleeping Gian s (12.91%) a e cha ac e ized by mode a e mone a y con ibu ions bu longe pe iods
o inac i i y.
25
4.1. RFM SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.1: Dis ibu ion o RFM Segmen s Analysis
Segmen S a is ics
The key s a is ics o each segmen a e p o ided in Table 4.1. The analysis o ecency, equency, and
mone a y me ics o e s deepe insigh s in o cus ome beha io :
•
Whales exhibi he sho es RecencyMean (5.93 days), highligh ing hei ecen ac i i y and s ong
b and loyal y.
•
In con as , Los Clien s show he longes RecencyMean (161 days) and minimal spending, signaling
he need o e-engagemen s a egies o exclusion om a ge ed campaigns.
•
Ac i e S a s ha e ela i ely high Mone a yMean (€3,156) and mode a e equency (6.52 ansac ions),
making hem a s able ye g owing segmen .
•
Sleeping Gian s demons a e po en ial wi h mode a e F equencyMean (5.15 ansac ions) and signi i-
can Mone a yMean (€2,656), sugges ing he need o ailo ed campaigns o eac i a e hei pu chasing
habi s.
Segmen
R
Mean
R
Me-
dian
F
Mean
F
Me-
dian
M
Mean
M
Me-
dian
Size
Ac i e S a s
17.10 17.80 6.52
5
3156 2500 679
Los Clien s
161.00 138.00 1.60
1
495 450 2044
Loyal Regula s
15.90 16.00 4.06
4
671 520 175
New & Occasional
17.60 18.50 1.66
2
464 390 532
Sleeping Gian s
88.20 68.00 5.15
4
2656 2400 560
Whales
5.93 4.94 18.20
13
11222 9500 348
Table 4.1: Segmen S a is ics o RFM Analysis
26
4.1. RFM SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
(a) RFM log R (b) RFM log M
(c) RFM log F
Figu e 4.2: Loga i hmic boxplo s o RFM indica o s
4.1.2 Clus e ing Resul s on RFM Segmen a ion
The clus e ing analysis on he RFM da a was pe o med using i e dis inc algo i hms: K-Means, DBSCAN,
Hie a chical Clus e ing, Gaussian Mix u e Model (GMM), and Fuzzy C-Means (FCM). Each me hod was
selec ed based on i s abili y o unco e pa e ns in he da a and p o ide meaning ul cus ome segmen a ion.
The clus e ing pa ame e s we e de e mined based on speci ic e alua ion echniques (e.g., he Elbow Me hod,
k-NN Dis ance Plo , BIC).
Below, we de ail he clus e ing esul s, including s a is ical summa ies, isualiza ions, and he a ionale o
pa ame e selec ion.
K-Means Clus e ing Resul s
The K-Means clus e ing algo i hm was applied o he no malized RFM da a o segmen he cus ome base
in o dis inc g oups. The op imal numbe o clus e s (k) was de e mined using he Elbow Me hod.
27
4.1. RFM SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.3: Elbow me hod g aph
Elbow Me hod o Op imal
k
:The Elbow Me hod g aph, depic ed in Figu e 4.3, iden i ies
k
= 4 as he
op imal numbe o clus e s. A his alue, he Wi hin Sum o Squa es (WSS) shows a signi ican educ ion
compa ed o
k
= 3, bu he a e o dec ease diminishes beyond
k
= 4. This choice s ikes a balance be ween
minimizing WSS and a oiding excessi e model complexi y.
So he K-Means algo i hm di ided he cus ome s in o ou clus e s. The de ailed clus e s a is ics a e shown
in Table 4.2.
Clus e
R
Mean
R
Me-
dian
F
Mean
F
Me-
dian
M
Mean
M
Me-
dian
Size
1 16.0 5.97 22.1 19
12510 7931
209
2 7.66 2.03 82.5 63
127338 117380
13
3
249.0 244.0
1.55 1 478 310
1061
4 44.5 33.0 3.66 3
1353
826
3055
Table 4.2: Clus e S a is ics o K-Means Clus e ing.
Visualiza ion: The dis ibu ion o cus ome s ac oss clus e s is isualized in Figu e 4.4, showing he Recency
and F equency dimensions. The Mone a y alue is ep esen ed by he size o he poin s, highligh ing he high
alue o Clus e 2.
28
4.1. RFM SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.4: K Means 2D g aph
Insigh s:
•
Clus e 2 consis s o high- equency cus ome s wi h ecen ansac ions and high mone a y con ibu ions,
making i a p ime a ge o e en ion s a egies. The o al mone a y alue ac oss all clus e s was
calcula ed as app oxima ely 8,910,557€. O his, Clus e 2 con ibu ed 1,655,394€, ep esen ing
18.58% o he o al. This signi ican con ibu ion om only 13 indi iduals highligh s he excep ional
spending beha io o his small segmen .
•
Clus e 1 and Clus e 4 ep esen mode a e- equency and mone a y cus ome s wi h di e ing ecency
p o iles.
•
Clus e 3, he la ges , includes in equen and low- alue cus ome s, emphasizing he need o a ge ed
engagemen s a egies o con e hem in o highe - alue segmen s.
DBSCAN Clus e ing Resul s
The Densi y-Based Spa ial Clus e ing o Applica ions wi h Noise (DBSCAN) algo i hm was applied o he
no malized RFM da a o iden i y clus e s o a ying shapes and densi ies. Unlike K-Means, DBSCAN does
no equi e he speci ica ion o he numbe o clus e s be o ehand and is pa icula ly e ec i e a iden i ying
noise poin s. Howe e , i is sensi i e o he pa ame e s eps (epsilon) and MinP s.
Pa ame e Selec ion o DBSCAN: The k-NN dis ance plo , shown in Figu e 4.5, was used o de e mine
an app op ia e alue o
eps
. A alue o
eps = 0.45
was selec ed, as his co esponds o he poin whe e
he k-NN dis ances begin o ise sha ply. MinP s was se o 5 (as al eady explained in he Me hodology).
Clus e S a is ics: DBSCAN iden i ied h ee g oups, including one noise clus e (
Clus e 0
). De ailed
s a is ics o each clus e a e p o ided in Table 4.3.
29
4.1. RFM SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.5: k-NN Dis ance Plo o DBSCAN Pa ame e Selec ion (eps = 0.45).
Clus e
R
Mean
R
Me-
dian
F
Mean
F
Me-
dian
M
Mean
M
Me-
dian
Size
0(Noise) 51.1 8.98 39.5
31
48452 30358
62
1
93.8 52.0 3.73
2
1376
659
4272
2
3.27 3.05
38 38
7413 7065
4
Table 4.3: Clus e S a is ics o DBSCAN Clus e ing.
Visualiza ion: The igu e 4.6 isualizes he DBSCAN clus e ing esul s.
Insigh s:
•
Clus e 0 (Noise): Su p isingly, he noise clus e con ains 62 cus ome s wi h excep ionally high
mone a y alues (Mone a y Mean = 48452€). These cus ome s likely ep esen ou lie s o high- alue
clien s who do no con o m o he dense egions o he RFM space iden i ied by DBSCAN. This aises
conce ns abou he algo i hm’s abili y o handle such c i ical da a poin s e ec i ely, as classi ying
impo an cus ome s as noise unde mines he segmen a ion’s s a egic alue.
•
Clus e 1: This clus e con ains he majo i y o cus ome s (G oup Size = 4272) wi h low equency
and mone a y alues. I ep esen s low- alue, in equen cus ome s, aligning wi h expec a ions o his
po ion o he da ase .
30
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
!h
Figu e 4.12: Fuzzy C-Means Clus e ing (Ha d Assignmen s)
Insigh s:
•
Clus e 1: encompasses he la ges g oup o cus ome s, wi h ela i ely a e age Recency and low
F equency and Mone a y alues, indica ing mode a ely engaged cus ome s.
•
Clus e 2: con ains less equen and less ecen buye s wi h low Mone a y con ibu ions, po en ially
ep esen ing disengaged o do man cus ome s.
•
Clus e 3: includes high- alue cus ome s wi h equen ansac ions and low Recency, aligning wi h
cha ac e is ics o highly engaged and aluable clien s.
•
Clus e 4: ep esen s he leas engaged cus ome s wi h e y low F equency and Mone a y alues,
ypically co esponding o long- ime inac i e clien s.
This ma ks he conclusion o he RFM segmen a ion and he associa ed clus e ing p ocesses. The nex
sec ion will add ess CLV-based segmen a ion, whe e he same clus e ing me hods will be applied. Since he
me hodology o ob aining he esul s has been ho oughly de ailed in his sec ion, he ocus will shi o he
in e p e a ion and commen a y o he ou comes.
4.2 CLV Segmen a ion & Clus e ing
4.2.1 CLV Segmen a ion
In his sec ion, we shi ou ocus om he RFM-based app oach o a Cus ome Li e ime Value (CLV)
pe spec i e. By inco po a ing a iables such as To alRe enue,F equency,A e age T ansac ion Value,Li espan,
and he de i ed CLV me ic, we aim o cap u e a mo e comp ehensi e iew o each cus ome ’s long- e m
wo h. The ollowing subsec ions de ail he clus e ing analysis pe o med on hese CLV-d i en ea u es,
p o iding insigh s in o cus ome segmen s ha can guide s a egic ma ke ing, e en ion, and acquisi ion
37
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
e o s.
4.2.2 Clus e ing Resul s on CLV Segmen a ion
K-Means Clus e ing Resul s
The K-Means algo i hm was applied o he no malized da ase con aining To alRe enue,F equency,A e age
T ansac ion Value,Li espan, and CLV. As in he RFM analysis, he op imal numbe o clus e s
k
was
de e mined using he Elbow Me hod.
Elbow Me hod o Op imal
k
:Figu e 4.13 illus a es he Elbow Me hod, whe e he Wi hin Sum o
Squa es (WSS) was plo ed agains he numbe o clus e s. A ma ked bend in he plo a
k
= 4 indica es
ha inc easing he numbe o clus e s beyond ou yields ma ginal gains in a iance educ ion. Consequen ly,
k= 4 was selec ed as he op imal solu ion.
Figu e 4.13: Elbow Me hod o K-Means (CLV Da a)
Clus e S a is ics: The K-Means algo i hm hus pa i ions he cus ome base in o ou clus e s, each
exhibi ing dis inc beha io s in e ms o e enue gene a ion, pu chase equency, and li e ime alue. Table 4.7
p o ides an o e iew o he key me ics o each clus e .
38
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
kC
TR
M
F M
CLV
M
AT
M
LS M
Size
1 2915 7.08
70,932
33.3 274 1753
2
122,828
1.50
11,512,288 66,671
102 2
3
84,711
72.30
3,396,779
192 363 23
4 628 1.74 2,369 39.2 30.9 2560
Table 4.7: K-Means Clus e S a is ics o CLV-Based Analysis
Legend:
kC K-Means Clus e ing
TR To al Re enue (€)
FF equency
CLV Cus ome Li e ime Value
AT A e age T ansac ion Value
LS Li espan (days)
MMean
Visualiza ion: Figu e 4.14 p esen s a 2D sca e plo o he clus e s in e ms o F equency and To alRe enue,
wi h poin size e lec ing he CLV magni ude. Addi ionally, Figu e 4.15 shows he ada cha o K-Means.
A ada cha is a g aphical me hod used o isualize mul i a ia e da a. Each a iable is ep esen ed by an
axis emana ing om he cen e , and he da a poin s a e plo ed on hese axes o o m a polygon. In his
con ex , ada cha s display he no malized a e ages o key me ics (e.g., To al Re enue, F equency, CLV)
o each clus e , o e ing a compac iew o hei unique cha ac e is ics.
Figu e 4.14: K-Means Clus e ing on CLV Da a (2D P ojec ion)
39
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.15: K-Means Rada Cha
Insigh s:
•
Clus e 2 (only 2 cus ome s) exhibi s ex emely high To alRe enue and A gT ansac ionValue, esul ing
in he la ges CLV by a . These ep esen “ul a-p emium” clien s, whe e pe sonalized e en ion and
upselling s a egies can be highly impac ul.
•
Clus e 3 s ands ou o i s ele a ed F equency (o e 70 pu chases on a e age) and a high CLV,
sugges ing a loyal and ac i e cus ome g oup. Fos e ing loyal y p og ams and subsc ip ion models could
u he cemen hese ela ionships.
•
Clus e 1 con ains mode a ely ac i e cus ome s wi h a no able li e ime alue, hough signi ican ly
lowe han Clus e 2 o 3. Ta ge ed campaigns can aim o inc ease hei pu chase equency o upsell
o boos hei A gT ansac ionValue.
•
Clus e 4 holds he la ges olume o cus ome s (2,560), bu wi h low To alRe enue,CLV, and
F equency. I could encompass one- ime o in equen buye s. Re-engagemen o c oss-selling s a egies
may help con e a po ion o his la ge g oup in o highe - alue segmen s.
Ha ing ou lined he CLV-based K-Means clus e ing, he ollowing subsec ions will compa e hese indings
wi h al e na i e clus e ing me hods (Hie a chical, DBSCAN, GMM, and Fuzzy C-Means) o u he alida e
o e ine he segmen a ion s a egy.
40
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Hie a chical Clus e ing Resul s
The Hie a chical Clus e ing app oach was applied o he same CLV-based da ase using Wa d’s minimum
a iance me hod (
wa d.D2
). This algo i hm ecu si ely me ges clus e s o minimize he o al wi hin-clus e
a iance, p oducing a dend og am ha illus a es he nes ed s uc u e o he da a.
De e mina ion o he Numbe o Clus e s: A isual inspec ion o he dend og am (Figu e 4.16) was
used o selec he cu o heigh , esul ing in
k= 4
clus e s. Rec angula bounda ies d awn on he dend og am
con i m his selec ion, balancing in e p e abili y agains clus e g anula i y.
Figu e 4.16: Hie a chical Clus e ing Dend og am (CLV Da a)
Clus e S a is ics (Means): Table 4.8 p o ides an o e iew o each clus e ’s mean alues o he key
a iables. The abb e ia ions a e explained in he legend below he able.
hC
TR
M
F M
CLV
M
AT
M
LS
M
Size
1
122,828
1.50
11,512,288 66,671
102 2
2 2,586 6.63
58,597
29.7 261 1,941
3 571 1.63 1,637 34.5 21.6 2,364
4
74,050
58.2
2,933,135
772 329 31
Table 4.8: Hie a chical Clus e ing (CLV) – Mean Values.
Legend: hC Hie a chical Clus e
41
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Clus e S a is ics (S anda d De ia ions): To u he assess a iabili y wi hin each clus e , Table 4.9
shows he co esponding s anda d de ia ions o he same me ics.
hC TR SD F SD
CLV
SD
AT SD LS SD
1 64,551 0.71
16,280,833
14,868 145
2 3,304 5.80 137,274 75.4 72.7
3 747 1.07 7,167 129 36.4
4 65,367 48.8
3,529,243
2,458 91.2
Table 4.9: Hie a chical Clus e ing (CLV) – S anda d De ia ions.
Visualiza ion: Figu e 4.17 shows a 2D p ojec ion o he ou hie a chical clus e s (colo -coded by clus e
membe ship), plo ed agains F equency and To alRe enue, wi h he poin size e lec ing he CLV. Addi ionally,
Figu e 4.18 shows he ada cha s o he Hie a chical Clus e ing
Figu e 4.17: Hie a chical Clus e ing on CLV Da a (2D P ojec ion)
42
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.18: hC Rada Cha s
Insigh s:
•hC 1: Wi h only 2cus ome s, i shows ex emely high To alRe enue and CLV, simila o he “ul a-
p emium” clus e iden i ied in K-Means. Re en ion and bespoke ma ke ing can ampli y he alue o
hese eli e clien s.
•
hC 2: The la ges clus e (1,941 cus ome s) wi h mode a e e enue and equency. Al hough hei
CLV is ela i ely modes , an upsell o c oss-sell app oach could unlock u he po en ial.
•
hC 3: A la ge g oup o low- alue and in equen buye s. This segmen may be ha de o con e , bu
e-engagemen campaigns o a ge ed p omo ions migh eac i a e some po ion.
•
hC 4: A niche bu e y ac i e clus e (F Mean
≈
58.2). Despi e gene a ing subs an ial e enue
(
≈
74
,
050), hey emain a behind he op- ie clus e in e ms o CLV. S eng hening loyal y p og ams
could inc ease hei a e age ansac ion alue.
These indings mi o ce ain pa e ns seen in he K-Means segmen a ion, albei wi h a ia ions in clus e size
and bounda ies. The manual selec ion o ou clus e s in oduces a deg ee o subjec i i y, ye he hie a chical
app oach o e s a mo e in ui i e iew o segmen cohesion and sepa a ion ia he dend og am.
DBSCAN Clus e ing Resul s
The DBSCAN algo i hm akes a densi y-based app oach, iden i ying dense egions in he CLV ea u e
space while designa ing low-densi y poin s as noise. Unlike cen oid-based me hods, DBSCAN au oma ically
de e mines he numbe o clus e s based on he pa ame e s eps and MinP s.
Pa ame e Selec ion: Ak-NN dis ance plo was gene a ed o guide he choice o
eps
. A e obse ing
in he igu e 4.19 a sha p inc ease in he dis ance alues nea
eps = 0.6
, his h eshold was adop ed, wi h
43
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.19: k-NN Dis ance Plo o DBSCAN Pa ame e s Selec ion (eps = 0.6)
MinP s se o 5. The algo i hm yielded 2main clus e s in he con ex o CLV da a.
Clus e S a is ics (Means): Table 4.10 p o ides he mean alues o each clus e , employing he same
no a ion used p e iously.
dbC
TR
M
F M
CLV
M
AT
M
LS
M
Size
0
39,506
35.2
1,746,547
2,184 296 81
1 1,342 3.68
21,162
28.1 128 4,257
Table 4.10: DBSCAN Clus e ing (CLV) – Mean Values.
Legend: dbC DBSCAN Clus e
Clus e S a is ics (S anda d De ia ions): Table 4.11 epo s he s anda d de ia ions o each me ic,
indica ing he dispe sion wi hin each clus e .
44
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
dbC TR SD F SD
CLV
SD
AT SD LS SD
0 52,305 36.9
3,448,736
10,585 113
1 1,928 4.03 56,020 53.4 131
Table 4.11: DBSCAN Clus e ing (CLV) – S anda d De ia ions.
Visualiza ion: The 2D plo in Figu e 4.20 illus a es he clus e s in e ms o F equency (
x
-axis) and
To alRe enue (y-axis), wi h he size o each poin co esponding o i s CLV.
Figu e 4.20: DBSCAN Clus e ing on CLV Da a (2D P ojec ion)
Insigh s:
•
Clus e 0: Comp ises only 81 cus ome s bu shows signi ican ly highe F equency,To alRe enue, and
CLV on a e age. The s anda d de ia ions (TR SD and CLV SD in pa icula ) a e no ably la ge,
indica ing a b oad ange o spending pa e ns wi hin his high- alue segmen .
•
Clus e 1: The as majo i y o cus ome s (o e 4,000), ma ked by modes e enue and low equency.
Al hough hei CLV emains compa a i ely small, a ge ed ma ke ing campaigns could po en ially li
a subse o hese cus ome s in o highe - alue b acke s.
•
Noise Poin s: DBSCAN ypically designa es isola ed o less dense egions as noise. In his da ase ,
howe e , mos cus ome s all in o one o he wo clus e s, sugges ing ha he chosen pa ame e s
e ec i ely cap u ed he p ima y da a s uc u e.
45
4.2. CLV SEGMENTATION & CLUSTERING CHAPTER 4. RESULTS
Figu e 4.21: DBSCAN Rada Cha s
In summa y, DBSCAN iden i ies a small bu highly aluable g oup o buye s (Clus e 0) alongside a la ge,
lowe - alue segmen (Clus e 1). The ele a ed SD me ics in Clus e 0 indica e di e se spending habi s,
me i ing a close look a sub-segmen a ion o pe sonalized o e s o high-spending indi iduals.
Gaussian Mix u e Model (GMM) Clus e ing Resul s
The Gaussian Mix u e Model (GMM) employs a p obabilis ic amewo k, assuming ha da a poin s
o igina e om a mix u e o Gaussian dis ibu ions. This lexibili y enables GMM o cap u e clus e s o
a ious shapes and densi ies, o en yielding mo e nuanced segmen a ions compa ed o s ic ly dis ance-based
app oaches.
Model Fi ing: In his analysis, he
Mclus
package was u ilized o au oma ically de e mine he op imal
numbe o componen s h ough he Bayesian In o ma ion C i e ion (BIC). The esul ing bes - i model
iden i ied 6clus e s in he CLV-based ea u e space.
Clus e S a is ics (Means): Table 4.12 p esen s mean alues o each o he six GMM clus e s, using he
abb e ia ed no a ion desc ibed in ea lie sec ions.
gC
TR
M
F M
CLV
M
AT
M
LS M
Size
1 304 1.00 0 19.6 0 1,393
2 35,999 26.1
1,750,038
2,513 208 75
3 643 2.00 3,721 17.6 104 730
4 5,705 10.5
156,058
102 217 333
5 1,211 4.60 12,095 13.4 204 1,083
6 2,911 7.23 44,922 27.1 252 724
Table 4.12: GMM Clus e ing (CLV) – Mean Values.
Legend: gC GMM Clus e
Clus e S a is ics (S anda d De ia ions): Table 4.13 displays he s anda d de ia ions, indica ing how
dispe sed each me ic is wi hin e e y clus e . No ably, gC 2 has a high CLV SD, e lec ing a b oad ange o
46
4.3. MODELS EVALUTATION CHAPTER 4. RESULTS
•
Hie a chical sligh ly ou pe o ms K-Means on he CH index (994
.
80 s. 989
.
23), sugges ing ha i
o e s ma ginally be e global sepa a ion o hese i e-dimensional ea u es (To alRe enue, F equency,
A e ageT ansac ionValue, Li espan, CLV ).
•
GMM again shows lowe pe o mance on bo h me ics (0
.
2012 Silhoue e, 260
.
48 CH), implying ha a
pu ely Gaussian mix u e app oach may no cap u e he i egula pa e ns o CLV dis ibu ions.
•
Fuzzy C-Means and K-Means demons a e compa ably mode a e Silhoue e sco es (a ound 0
.
62),
bu wi h K-Means pe o ming be e on he CH index. This dynamic again unde sco es how ce ain
algo i hms may excel in local cohesion ye di e in global a iance pa i ioning.
Summa y o Model E alua ion
•
DBSCAN consis en ly yields high Silhoue e sco es in bo h RFM and CLV da ase s, indica ing
well-de ined clus e s in e ms o local densi y. Howe e , i s CH sco es, hough decen , all sho o hose
o K-Means o Hie a chical in some cases.
•
K-Means and Hie a chical o en domina e he Calinski–Ha abasz index, sugges ing hey p oduce
b oade in e -clus e sepa a ion ela i e o in a-clus e a iance. Hie a chical clus e ing shows a sligh
edge o e K-Means o he CLV da a’s CH index.
•
GMM lags behind o he me hods ac oss bo h me ics, o easons likely ied o he non-Gaussian
dis ibu ion o he chosen ea u es (RFM o CLV).
•
Fuzzy C-Means pe o ms mode a ely in bo h me ics, especially o CLV. I p o ides lexibili y
h ough so membe ships bu may no ma ch he clus e compac ness o sepa a ion o DBSCAN,
K-Means, o Hie a chical me hods in his con ex .
In conclusion, he choice o clus e ing me hod depends hea ily on whe he he p ima y goal is local cohesion
s. global sepa a ion. Fo local, densi y-d i en segmen a ion (as indica ed by Silhoue e), DBSCAN equen ly
eme ges as he bes candida e. Fo maximizing be ween-clus e a iance (as indica ed by he Calinski–Ha abasz
index), K-Means o Hie a chical may be p e e ed. The nex chap e discusses hese indings in de ail and
ou lines po en ial use-cases and u u e di ec ions o applying he a ious clus e ing me hodologies.
53
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Chap e 5
Conclusions
O e all, his hesis has compa a i ely analyzed cus ome segmen a ion s a egies based on he RFM
(Recency, F equency, Mone a y) and CLV (Cus ome Li e ime Value) models, in eg a ing hem wi h
i e dis inc clus e ing algo i hms: K-Means,Hie a chical Clus e ing,DBSCAN,Gaussian Mix u e Models
(GMM) and Fuzzy C-Means (FCM). The aim was o ho oughly in es iga e how di e en segmen a ion
echniques can p o ide use ul indica ions on bo h a ac ical and s a egic basis, highligh ing hei espec i e
s eng hs and weaknesses. The esul s ob ained p o ide signi ican conside a ions bo h om a me hodological
and a p ac ical-applica i e poin o iew.
1. Summa y o Objec i es and Con ex
The hesis is placed in he b oade pano ama o Cus ome Rela ionship Managemen (CRM) and da a-d i en
ma ke ing, whe e cus ome segmen a ion plays a cen al ole in op imizing esou ces and maximizing he
e u n on in es men o campaigns. In pa icula , he use o he RFM model allows o in e p e pu chasing
beha io s in e ms o empo al p oximi y (Recency), ansac ion equency (F equency) and mone a y alue
(Mone a y). Al hough ex emely widesp ead o i s in e p e a i e simplici y, he RFM model has some
limi a ions when i comes o e alua ing he u u e economic po en ial o a cus ome . Fo his eason, he
concep o CLV has also been included, which conside s es ima ed u u e pu chases, he du a ion o he
ela ionship wi h he cus ome (li espan) and o he pa ame e s ha can gi e a long- e m iew on he economic
alue ha can be gene a ed.
Algo i hmically, each o he i e clus e ing me hods o e s a di e en pe spec i e:
•
K-Means and Fuzzy C-Means use a cen oid-based app oach, use ul o ob aining compac g oups, and
di e in membe ship (ha d s. uzzy).
•
Hie a chical Clus e ing (pa icula ly wi h Wa d.D2) builds a hie a chy o clus e s, which is use ul when
explo ing he nes ed s uc u e o da a.
•
DBSCAN iden i ies egions o high densi y by sepa a ing hem om a eas o lowe densi y (classi ied as
54
CHAPTER 5. CONCLUSIONS
noise), wi hou he need o ix he numbe o clus e s a p io i.
•
GMM adds a p obabilis ic app oach, assuming ha he da a comes om a mix u e o Gaussian
dis ibu ions, each wi h i s own mean and a iance.
The s a ing da a se , coming om he UCI Machine Lea ning Reposi o y, was i s cleaned and p e- ea ed
(including emo al o duplica es, managemen o ou lie s and da e con e sion). Fo he RFM pa , h ee
undamen al indica o s we e calcula ed (Recency,F equency,Mone a y), while o he CLV pa , To alRe enue,
A e age T ansac ion Value,F equency,Li espan and he es ima e o CLV i sel we e in oduced. Once
hese se s o a iables we e ob ained, we p oceeded wi h he applica ion and compa ison o he clus e ing
algo i hms, also e alua ed h ough he in e nal me ics Silhoue e Sco e and Calinski–Ha abasz Index.
2. Key Findings in RFM Analysis
2.1 De aul RFM Segmen s
A i s analysis di ided cus ome s in o six segmen s (Whales, Ac i e S a s, Loyal Regula s, New &
Occasional Buye s, Sleeping Gian s, Los Clien s) based on he RFM sco es calcula ed wi h he
quin ile me hod. This ”manual” ca ego iza ion indica ed ha almos hal o he cus ome s (o e 47%) all
in o he Los Clien s, i.e. cus ome s who do no show ecen o equen pu chases, wi h an o e all modes
spending alue. On he o he hand, a small g oup o Whales (jus o e 8%) gene a es a spending olume ha
is eno mously highe han he a e age, placing i sel as a op p io i y segmen o e en ion o c oss-selling
s a egies.
2.2 Compa ison o Clus e ing Algo i hms (RFM)
•
K-Means: I highligh ed 4 clus e s (de e mined by Elbow Me hod). One o hese (Clus e 2) includes
e y ew cus ome s (13) wi h high mone a y con ibu ion (
∼
18.5% o he o al), con i ming he exis ence
o an eli e g oup wi h e y high economic alue.
•
DBSCAN: I iden i ied 3 clus e s, one o which is classi ied as noise (Clus e 0) and con ains cus ome s
wi h an e en mo e ou o scale spending p o ile. This highligh s a po en ial limi o DBSCAN, which
ends o isola e he “ex eme” poin s and classi y hem as noise i he
ϵ
and MinP s pa ame e s a e no
calib a ed e y ca e ully.
•
Hie a chical Clus e ing: Wi h a cu o 7 clus e s, i allowed o iden i y in a g anula way segmen s
o cus ome s wi h high equency and mone a y alue, including some segmen s o minimum size bu
e y high alue (
M≈
164
,
658 in one case). The hie a chical app oach is e y anspa en , allowing o
isualize how he g oupings a e o med h ough a dend og am, al hough he choice o he cu poin
emains subjec i e.
•
GMM: I e ealed 9 clus e s o he RFM da ase , a a he high numbe . He e oo, a small g oup o
cus ome s (Clus e 9) wi h an ex emely high a e age mone a y alue (o e 46,000 €) and a se ies o
55
CHAPTER 5. CONCLUSIONS
”in e media e” clus e s wi h a ious composi ions eme ge. This shows he abili y o GMM o cap u e
nuances, bu aises doub s abou he in e p e abili y o segmen a ions ha a e oo agmen ed.
•
Fuzzy C-Means (FCM): By se ing 4 clus e s (in line wi h K-Means), i dis ibu ed he cus ome s in
a less clea -cu way. Thanks o he uzzy membe ship, some cus ome s a e posi ioned be ween mul iple
g oups, e lec ing ha in eal si ua ions he beha io al bounda ies a e no always clea . Howe e , he
in e p e a ion o he ”pa ial membe ships” equi es a g ea e analy ical e o .
2.3 Applica ion In e p e a ions
The RFM analysis shows ha ”high-spending” cus ome s a e o en ew bu decisi e o he u no e . This
sugges s ha he RFM segmen a ion—wi h i s immediacy o calcula ion—is excellen o ac ical snapsho s,
such as planning seasonal campaigns o iden i ying inac i e clus e s (Los Clien s) o eco e . Howe e , i
he decision ho izon ex ends o long- e m conside a ions (e.g. es ima e o u u e e enues o he p obabili y
o cus ome ”su i al”), RFM isks losing i s e ec i eness because i does no inco po a e he p ospec i e
empo al dynamics.
3. Main E idence in CLV Analysis
3.1 Va ious De ini ions o Long-Te m Value
The second pa o he hesis ocused on he CLV, calcula ed by in eg a ing o al spen , equency,a e age
alue pe ansac ion and li espan o he cus ome , o ob ain a me ic ha summa izes he po en ial e u n
o e a p olonged ime pe iod. This pe spec i e be e in e cep s ma ke ing s a egies o ien ed o he balance
be ween main aining he ”bes cus ome s” and acqui ing new high-po en ial ones.
3.2 Compa ison o Clus e ing Algo i hms (CLV)
•
K-Means: Wi h
k
= 4, i was highligh ed how a e y small clus e (only 2 cus ome s) has an
ex ao dina y a e age CLV, highe han 11 million eu os. A second clus e (23 cus ome s) shows e y
high equency and obus CLV, while he majo i y alls in o low o medium alue clus e s.
•
Hie a chical Clus e ing: I p o ided 4 clus e s, one o which is again occupied by a ew ul a-p emium
cus ome s, and ano he by cus ome s wi h ela i ely high equency. The hie a chical app oach con i ms
he p esence o la ge masses o low- alue cus ome s and eli e mino i ies wi h ex eme pa ame e s.
•
DBSCAN: De ec ed only 2 main clus e s, sepa a ing a g oup o 81 ” op spende s” (Clus e 0) om
he es (Clus e 1, o e 4000 low CLV cus ome s). This clea sepa a ion, while easy o in e p e ,
neglec s he p esence o possible subs uc u es wi hin he high- alue g oup, as sugges ed by GMM o
he dend og am.
•
GMM: Es ima es 6 clus e s ia BIC-based mclus . Di e en g ada ions o high- alue cus ome s eme ge,
including hose who make a single, e y expensi e pu chase and hose who ha e e y high equencies,
56
CHAPTER 5. CONCLUSIONS
wi h a ied beha io s. The isk, as always, is o e -segmen a ion, which could be oo g anula o lean
ma ke ing plans.
•
Fuzzy C-Means: Se on 4 clus e s, i ei e a ed he exis ence o an excep ional mic o-segmen ( C 3
wi h jus 7 cus ome s bu a e age CLV
>
10 million) and a medium-high segmen ( C 2) wi h abou
333 cus ome s. Mos o he popula ion emained in low- alue clus e s ( C 1 and 4), highligh ing a la ge
po ion o cus ome s ha , in an upselling pe spec i e, could be encou aged o g ow.
4. Compa a i e Conside a ions: RFM s. CLV
A cen al elemen o his wo k consis s in he compa ison be ween he segmen a ion based on RFM and ha
based on CLV. Bo h models iden i y ew cus ome s wi h e y high economic alue and many cus ome s wi h
low spending. Howe e :
1. Time ho izon:
•
RFM a o s he cu en beha io . I a cus ome wi h high pas pu chases s ops buying o a ew
mon hs, in he RFM Recency will ge wo se, and ha indi idual could mo e om a ”high-spending”
clus e o a less desi able one.
•
CLV ins ead es ima es he u u e p opensi y, possibly ecognizing high spending ma gins i
his o ically he equency has been high and he analysis ime window sugges s a p obabili y o
epu chase.
2. S a egic:
•
RFM lends i sel o sho -medium e m di ec ma ke ing ( o example, how o launch a Ch is mas
p omo ion o a e a ge ing ac ion on ecen ly inac i e cus ome s).
•
CLV is mo e connec ed o s a egic decisions: de ining acquisi ion budge s, p edic i ely e alua ing
he e ec i eness o in es men s in e en ion, jus i ying ex eme cus omiza ion o he ” op ie s”.
3. Compu a ion Complexi y:
•RFM is simple and easily adop able by companies wi h basic IT in as uc u es.
•
CLV calcula ion equi es o ecas s o hypo heses on u u e beha io and equi es models o
assump ions (e.g. discoun a es, es ima ed e en ion a e), making he p ocedu e mo e complex.
4. Segmen a ion S abili y:
•
RFM sco es can luc ua e apidly when he ime dimension a ies (a cus ome conside ed ecen
oday may no be so in a ew weeks).
•
CLV o e s a mo e s able pic u e, a leas as long as he calcula ion assump ions emain alid.
Howe e , i pu chasing pa e ns change d ama ically, CLV es ima es should also be ee alua ed.
57
CHAPTER 5. CONCLUSIONS
5. Clus e ing Algo i hm Selec ion
No algo i hm has p o en o be unques ionably “bes ” o e all: i s quali y depends on he business goals, he
shape o he da a, and whe he o no i is necessa y o ha e well-sepa a ed clus e s s. luid clus e s.
•
K-Means: Ideal i you wan a as segmen a ion ha can be in e p e ed in e ms o cen oids, p o ided
you de ine he numbe o clus e s well and wo k on da a wi hou s ong ou lie s.
•
Hie a chical: Excellen o explo a o y analysis and o isualizing he da a s uc u e using dend o-
g ams; de e mining he clus e cu emains subjec i e, howe e .
•
DBSCAN: Use ul o inding dense mic o-clus e s and o highligh ing ou lie s, bu i can ma ginalize
aluable cus ome s by labeling hem as “noise” i ϵand MinP s a e no calib a ed co ec ly.
•
GMM: O e s a high deg ee o lexibili y and can accommoda e complex dis ibu ion shapes; howe e ,
i isks “o e -spli ing” he sample, especially i he da a does no ollow ue Gaussian shapes.
•
Fuzzy C-Means: I is ad an ageous when cus ome s a e expec ed o ha e “mul iple a ini ies” o
mul iple clus e s (e.g., a cus ome who buys bo h “p emium” and “s anda d” p oduc s). Howe e ,
in e p e ing uzzy membe ships equi es an addi ional s ep compa ed o he mo e common ha d
clus e ing.
6. Manage ial Implica ions
The dis inc ions be ween RFM and CLV, coupled wi h he a ying cha ac e is ics o clus e ing algo i hms,
p o ide nume ous insigh s o de eloping ope a ional s a egies:
1. Cus ome Po olio Managemen
•
Iden i y Whales o High-CLV segmen s as p io i ies o exclusi e campaigns, such as pe sonalized
discoun s, ea ly access o p oduc s, and dedica ed cus ome se ice.
•
Fo la ge low- alue clus e s (Los Clien s in RFM o clus e s o “one- ime s” in CLV), i is
ad isable o implemen cos -e ec i e ac ions. S a egies may include mass ac ions (e.g., gene ic
email ma ke ing) o selec i e eco e y e o s (e.g., a ge ed discoun s, loyal y packages), as
in es ing in expensi e s a egies o hese segmen s does no yield signi ican added alue.
2. Resou ce Op imiza ion
•
Alloca e ma ke ing esou ces (budge , ime, con ac s) p opo ionally o he po en ial alue o each
clus e . Speci ically, CLV can jus i y g ea e in es men s in e aining op cus ome s, whe e a high
e u n is an icipa ed in he long e m.
3. Loyal y and C oss-Selling P og ams
•
Encou age segmen s wi h high F equency bu mode a e uni spending o pu chase highe -ma gin
p oduc s h ough c oss-selling (o e ing ela ed o complemen a y p oduc s) and up-selling (en-
58
CHAPTER 5. CONCLUSIONS
cou aging he pu chase o mo e expensi e i ems) ini ia i es.
•
Ta ge segmen s wi h low Recency bu a his o y o subs an ial spending (Sleeping Gian s) wi h
pe sonalized “win-back campaigns” (s a egies aimed a e-engaging inac i e cus ome s).
4. Compe i ion and O e Analysis
•
I a company obse es ha cus ome s wi hin a speci ic clus e a e mig a ing o compe i o s,
co ec i e measu es can be adop ed, such as imp o ing se ice quali y, educing deli e y imes, o
launching a ge ed p omo ions.
•
RFM and CLV me ics can se e as in e nal benchma ks o moni o how cus ome dis ibu ions
ac oss segmen s e ol e o e ime.
5. Da a-D i en Cul u e
•
Implemen in e nal dashboa ds ha allow manage s o explo e RFM and CLV me ics in eal ime
(o nea eal ime).
•
The syne gy be ween he wo pe spec i es (sho - o medium- e m RFM and long- e m CLV)
ein o ces a co po a e cul u e based on da a and p edic i e analysis, a he han solely on ins inc i e
decision-making.
7. Limi a ions and Fu u e Pe spec i es
Al hough he esea ch has p o ided impo an insigh s, he e a e some aspec s o conside o possible u u e
de elopmen s:
1. Da a Quali y and Upda ing
•
The analyzed da ase , al hough obus , e lec s a speci ic pe iod o ime (abou a yea o ans-
ac ions). In eal con ex s, he da a should be con inuously upda ed, and he clus e ing models
“ ecu si ely” ecalib a ed.
•
The possible p esence o seasonali y (Ch is mas pe iod, Black F iday, e c.) could al e he alues
o Recency and F equency signi ican ly.
2. Rele ance o Addi ional Va iables
•
Bo h RFM and CLV igno e dimensions such as p oduc ca ego y, ne p o i abili y (which would
equi e conside ing cos s and ma gins), demog aphics (age, loca ion) o beha io al a iables
( eedback, e iews, e u n a e). In eg a ing addi ional da a sou ces could e ine he segmen a ion,
bu make he calcula ion mo e complex.
3. Clus e ing Pa ame e s
•
DBSCAN, o example, is ex emely sensi i e o he choice o
ϵ
. The same is ue o GMM, which
can e u n a a iable numbe o clus e s based on he BIC. G ea e me hodological obus ness could
59
CHAPTER 5. CONCLUSIONS
include a mo e sophis ica ed model selec ion (c oss-e alua ion o mul iple me ics and compa isons
wi h simula ed da a).
4. Ad anced Machine Lea ning Applica ions
•
I segmen a ion is combined wi h p edic i e models (e.g. chu n o ecas ing o p opensi y sco ing),
e en mo e a ge ed esul s can be ob ained. Me hods such as deep clus e ing could be es ed in
con ex s wi h la ge amoun s o uns uc u ed da a (clicks eam, na iga ion logs).
5. Ex e nal Valida ion
•
In his wo k, in e nal alida ion me ics we e used (Silhoue e,Calinski–Ha abasz). I would be
use ul o in eg a e an ex e nal alida ion, measu ing he ac ual impac o each clus e on eal
business me ics (e.g. edemp ion a e o campaigns, upg ade a e o p emium plans, e c.).
8. O e all Conclusion
Ul ima ely, his hesis has shown how, in a ma ke ing and CRM con ex , he choice be ween RFM and CLV
and he selec ion o a pa icula clus e ing algo i hm canno be educed o uni e sal ules alid o all. On
he con a y, i is necessa y o conside :
•
The na u e o he da a: A da ase wi h many ou lie s and a highly skewed dis ibu ion can bene i
om he mos lexible clus e ing models (DBSCAN, GMM), as long as pa ame e s ha dis o i s
in e p e a ion a e a oided ( o example, e oneously de ining aluable cus ome s as “noise”).
•
The ime ho izon and s a egy: I ma ke ing ac ions aim o eco e inac i e cus ome s o he las ew
mon hs, RFM is an immedia e indica o . I , on he o he hand, i is a ques ion o in es ing in long- e m
loyal y p og ams, CLV becomes cen al.
•
The desi ed g anula i y: K-Means and FCM allow a ixed numbe o clus e s, while DBSCAN, GMM
and Hie a chical can po en ially c ea e mo e o less segmen s, p o ing use ul o dispe si e depending
on he case.
•
The ease o in e p e a ion: The adop ion o a ce ain me hod should always ake in o accoun he
possibili y o communica ing he esul s clea ly o business decision-make s. An excessi e agmen a ion
in o poo ly dis inguishable clus e s isks con using manage s a he han helping hem.
This wo k con ibu es o he li e a u e on cus ome analy ics by demons a ing how di e en clus e ing
me hods can lead o pa ly di e gen in e p e a ions, especially in he p esence o highly he e ogeneous da a
and wi h ew indi iduals gene a ing he majo i y o he e enue. Howe e , he “complemen a y” na u e o
RFM and CLV me ics sugges s ha he ideal choice o en consis s in combine bo h pe spec i es. Fo
example, a company could de ine p ima y clus e s using RFM (quick o upda e and in e p e ), and hen
p io i ize cus ome s wi h he highes CLVs wi hin each clus e .
F om an ope a ional pe spec i e, he esul s ob ained p o ide a p ac ical amewo k o hose wi hin he
o ganiza ion who wan o iden i y, desc ibe and e ain he bes cus ome s, wi hou neglec ing con e sion
60
CHAPTER 5. CONCLUSIONS
oppo uni ies among he ”“a e age” g oups o eco e y o do man g oups. The oad o uly pe sonalized
ma ke ing passes h ough he con inuous e olu ion o hese models: i e a ing he segmen a ion wi h upda ed
da a, inse ing new a iables ha p o ide addi ional le els o dep h (ne p o i abili y, pu chase p e e ences,
channels used, social media in e ac ions) and compa ing he hypo heses wi h angible economic esul s.
In summa y, he hesis ein o ces he idea ha he e is no ”“one size i s all” o cus ome segmen a ion.
Each business con ex and each ma ke ing objec i e equi e ailo -made analyses, bo h in e ms o he
de ini ion o me ics (RFM s. CLV, o a mix o bo h) and he choice o he clus e ing algo i hm. In he long
un, a hyb id and i e a i e app oach appea s o be he mos solid solu ion, whe e he esul s o one ool
(e.g. RFM) a e en iched and alida ed by he pe spec i es o ano he (CLV), and whe e mul iple clus e ing
me hods a e compa ed o cap u e he pa e ns ha bes e lec he ma ke s uc u e and business needs.
This app oach allows o acqui e an in eg a ed ision and o d aw inc easingly e ec i e da a-d i en decisions
in he cu en compe i i e con ex .
61
Compa a i e S udy o Cus ome Segmen a ion S a egies Based on Business Analy ics
Bibliog aphy
1.
SMITH, Wendell R. P oduc Di e en ia ion and Ma ke Segmen a ion as Al e na i e Ma ke ing
S a egies. Jou nal o Ma ke ing. 1956, ol. 21, no. 1, pp. 3–8.
2.
TEICHERT, Tho s en. Cus ome Segmen a ion Re isi ed: The Case o he Ai line Indus y. Jou nal o
Ai T anspo Managemen . 2008, ol. 14, no. 6, pp. 329–336.
3.
CHUNG, K. H.; CHEN, M. RFM Analysis: A Balancing Ac Be ween Business In elligence and Ma ke ing
In elligence. Indus ial Managemen & Da a Sys ems. 2016, ol. 116, no. 2, pp. 20–33.
4.
KHAJVAND, Mahboubeh; ZOLFAGHAR, Kiyana; ASHRAFI, M.; ALIZADEH, S. Es ima ing Cus ome
Li e ime Value Based on RFM Analysis o Cus ome Pu chase Beha io : Case S udy. P ocedia Compu e
Science. 2011, ol. 3, pp. 57–63.
5.
CHRISTY, T.; B., Noo Raihani; D., Gunawan D. Enhancing RFM Analysis wi h Weigh ing. P oceedings
o he In e na ional Con e ence on Compu ing and In o ma ics. 2018, ol. 7, pp. 84–91.
6.
GUPTA, S.; LEHMANN, D. R.; STUART, J. A. Valuing Cus ome s. Jou nal o Ma ke ing Resea ch.
2006, ol. 41, no. 1, pp. 7–18.
7.
VILLANUEVA, J.; HANSSENS, D. M. Cus ome Equi y: Measu emen , Managemen and Resea ch
Oppo uni ies. Founda ions and T ends in Ma ke ing. 2007, ol. 1, no. 1, pp. 1–95.
8.
LEMMENS, A.; CROUX, C. Bagging and Boos ing Classi ica ion T ees o P edic Chu n. Jou nal o
Ma ke ing Resea ch. 2006, ol. 43, no. 2, pp. 276–286.
9.
PAKHIRA, M. K.; BANDYOPADHYAY, S.; MAULIK, U. Validi y Index o C isp and Fuzzy Clus e s.
Pa e n Recogni ion. 2004, ol. 37, no. 3, pp. 487–501.
10.
PHAM, D. T.; DIMOV, S. S.; NGUYEN, C. D. Selec ion o K in K-Means Clus e ing. P oceedings
o he Ins i u ion o Mechanical Enginee s, Pa C: Jou nal o Mechanical Enginee ing Science. 2005,
ol. 219, no. 1, pp. 103–119.
11.
FALLIS, A. D. Hie a chical Clus e ing App oaches o La ge Scale Da a. Jou nal o Big Da a Analysis.
2013, ol. 2, no. 1, pp. 35–41.
12. EVERITT, B. S.; LANDAU, S.; LEESE, M.; STAHL, D. Clus e Analysis. 5 h. Wiley, 2011.
13.
ESTER, M.; KRIEGEL, H.-P.; SANDER, J.; XU, X. A Densi y-Based Algo i hm o Disco e ing
Clus e s in La ge Spa ial Da abases wi h Noise. In: P oceedings o he Second In e na ional Con e ence
on Knowledge Disco e y and Da a Mining. AAAI P ess, 1996, pp. 226–231.
62
5.1. RFM ANALYSIS, CLUSTERING CODE AND EVALUTATION BIBLIOGRAPHY
231 xaxis = lis ( i le =’ ecency’, ype = ’ log ’),
232 yaxis = lis ( i le =’ equency ’, ype = ’ log ’),
233 zaxis = lis ( i le =’mone a y ’, ype = ’ log ’)
234 )
235 )
236
237 gmm _s a s <- clus e _s a is ics (RFM , "gmm_clus e ")
238 p in (gmm_s a s )
239
240 # ######### hie a chical ##########
241 dis _ma ix <- dis (RFM_no malized )
242 hc_ model <- hclus ( dis _ma ix , me hod = " wa d . D2")
243 RFM $hie a chical_clus e <- as. ac o ( cu ee ( hc _model , k = 7))
244
245 plo (hc_ model ,labels = FALSE , main = " hie a chical clus e ing dend og am ",
246 xlab = "" ,sub =" wa d me hod ")
247 ec . hclus ( hc _model , k = 7, bo de = " ed ")
248
249 dend o <- as. dend og am ( hc_ model )
250 dend o_da a <- dend o_da a( dend o )
251
252 k<- 7
253 clus e _assignmen s <- cu ee(hc_ model , k)
254 labels _ d <- da a . ame ( label = ownames ( RFM _no malized ) , clus e = clus e _assignmen s ,
s ingsAsFac o s = FALSE)
255 labels _ d <- me ge (labels_d , dend o_da a$labels ,by =" label ")
256
257 ec _ da a <- agg ega e (x ~clus e , da a =labels _d , FUN = unc ion (x) c(min (x), max (x)))
258 ec _da a <- do.call( bind,lapply(1: n ow( ec _da a), unc ion (i) {
259 da a. ame (
260 clus e = ec _da a$clus e [i],
261 xmin = ec _da a$x[i, 1],
262 xmax = ec _da a$x[i, 2],
263 ymin = 0,
264 ymax = max(dend o_da a$segmen s $yend) /2
265 )
266 }))
267
268 ggplo () +
269 geom_segmen (da a = dend o_da a$segmen s ,
270 aes (x = x, y = y, xend = xend , yend = yend )) +
271 geom_ ec (da a = ec _da a ,
272 aes (xmin = xmin , xmax = xmax , ymin = ymin , ymax = ymax , ill = as. ac o (clus e
)),
273 alpha = 0.3) +
274 scale _ ill_manual ( name = "clus e ",
275 alues = c("# FF6666 " ,"#FFCC66"," #66 CC66 ","#66 CCCC "," #6666 FF " ,"#
CC66FF","#FF66CC")) +
276 labs( i le =" hie a chical clus e ing dend og am ", x = "clien s", y = "heigh ") +
69
5.1. RFM ANALYSIS, CLUSTERING CODE AND EVALUTATION BIBLIOGRAPHY
277 heme _minimal () +
278 heme ( axis. ex .x = elemen _blank () , axis. icks . x = elemen _blank () , legend. posi ion = "
igh ")
279
280 # zoom on some clus e s
281 zoom_xmin <- min ( ec _da a$xmin[ ec _da a$clus e %in% c(5 , 6, 7) ])
282 zoom_xmax <- max ( ec _da a$xmax[ ec _da a$clus e %in% c(5 , 6, 7) ])
283 zoom_ymax <- max (dend o_da a$segmen s $yend)
284
285 ggplo () +
286 geom_segmen (da a = dend o_da a$segmen s ,
287 aes (x = x, y = y, xend = xend , yend = yend )) +
288 geom_ ec (da a = ec _da a[ ec _da a$clus e %in% c(5 , 6, 7) , ],
289 aes (xmin = xmin , xmax = xmax , ymin = ymin , ymax = ymax , ill = as. ac o (clus e
)),
290 alpha = 0.3) +
291 scale _ ill_manual ( name = "clus e ",
292 alues = c("# FFCC66 " ,"#66 CC66","#FF6666")) +
293 coo d _ca esian ( xlim = c(zoom_xmin , zoom_xmax), ylim = c(0 , zoom_ymax /3) ) +
294 labs( i le =" zoom on clus e s 5, 6, and 7" ,x="clien s", y = "heigh ") +
295 heme _minimal () +
296 heme ( axis. ex .x = elemen _blank () , axis. icks . x = elemen _blank () , legend. posi ion = "
igh ")
297
298 ggplo (RFM , aes (x = Recency , y = F equency , size = Mone a y , colo = hie a chical _clus e ))
+
299 geom_poin ( alpha = 0.7) +
300 labs( i le =" hie a chical clus e ing ( m )" ,x=" ecency", y = " equency ") +
301 heme _minimal()
302
303 plo _ly(
304 da a = RFM ,
305 x = ~Recency ,
306 y = ~F equency ,
307 z = ~Mone a y,
308 colo = ~hie a chical_clus e ,
309 ype = " sca e 3d ",
310 mode ="ma ke s",
311 ma ke = lis ( size = 4)
312 ) %>%
313 layou (
314 i le =" hie a chical clus e ing ( log scale )" ,
315 scene = lis (
316 xaxis = lis ( i le =’ ecency’, ype = ’ log ’),
317 yaxis = lis ( i le =’ equency ’, ype = ’ log ’),
318 zaxis = lis ( i le =’mone a y ’, ype = ’ log ’)
319 )
320 )
321
70
5.1. RFM ANALYSIS, CLUSTERING CODE AND EVALUTATION BIBLIOGRAPHY
322 hie a chical_s a s <- clus e _s a is ics ( RFM , "hie a chical_clus e ")
323 p in (hie a chical_s a s )
324
325 # ######### uzzy c- means ##########
326 se .seed (333)
327 cm _ esul <- cmeans ( RFM _no malized , cen e s = k_op imal , m = 2, i e .max = 100 , e bose =
FALSE )
328 RFM $ uzzy _clus e <- apply ( cm _ esul $membe ship , 1, which .max)
329
330 ggplo (RFM , aes (x = Recency , y = F equency , size = Mone a y , colo = ac o ( uzzy _clus e )))
+
331 geom_poin ( alpha = 0.7) +
332 labs( i le =" uzzy c - means clus e ing ( m )" , x = " ecency",y=" equency ") +
333 heme _minimal()
334
335 sample_indices <- sample (1:n ow(RFM _no malized ), 20)
336 sample_membe ship <- cm _ esul $membe ship [ sample_indices , ]
337 membe ship _d <- as.da a. ame (sample_membe ship )
338 membe ship _d $Clien <- pas e ("clien ", 1: n ow( membe ship _d ))
339 membe ship _long <- mel ( membe ship _d , id. a s = "Clien ",
340 a iable . name = "Clus e ", alue . name = " Membe ship ")
341
342 ggplo ( membe ship _long , aes(x = Clus e , y = Clien , ill = Membe ship )) +
343 geom_ ile ( colo = " whi e " ) +
344 scale _ ill_g adien ( low = " ligh blue ", high = " da kblue ", name = " membe ship ") +
345 labs( i le =" uzzy c- means membe ship ( sample )", x = "clus e ", y = " clien ") +
346 heme _minimal () +
347 heme ( axis. ex .x = elemen _ ex ( size = 10) ,
348 axis. ex .y = elemen _ ex ( size = 8, angle = 45, hjus = 1) ,
349 axis. icks = elemen _blank ())
350
351 plo _ly(
352 da a = RFM ,
353 x = ~Recency ,
354 y = ~F equency ,
355 z = ~Mone a y,
356 colo = ~ ac o ( uzzy _clus e ),
357 ype = " sca e 3d ",
358 mode ="ma ke s"
359 ) %>%
360 layou (
361 i le =" uzzy c - means clus e ing ( log scale ) ",
362 scene = lis (
363 xaxis = lis ( i le =’ ecency’, ype = ’ log ’),
364 yaxis = lis ( i le =’ equency ’, ype = ’ log ’),
365 zaxis = lis ( i le =’mone a y ’, ype = ’ log ’)
366 )
367 )
368
71
5.1. RFM ANALYSIS, CLUSTERING CODE AND EVALUTATION BIBLIOGRAPHY
369 uzzy _s a s <- clus e _s a is ics (RFM , " uzzy _clus e ")
370 p in ( uzzy _s a s )
371
372 # ######### e alua ion ( silhoue e &ch index ) ##########
373 dis _ma ix <- dis (RFM_no malized )
374
375 silhoue e _kmeans <- silhoue e ( as.nume ic( RFM $kmeans_clus e ) , dis _ma ix)
376 silhoue e _dbscan <- silhoue e ( as.nume ic( RFM $dbscan_clus e ) , dis _ma ix)
377 silhoue e _hie a chical <- silhoue e ( as.nume ic( RFM $hie a chical_clus e ) , dis _ma ix)
378 silhoue e _gmm <- silhoue e ( as.nume ic( RFM $gmm _clus e ) , dis _ma ix)
379 silhoue e _ uzzy <- silhoue e ( as.nume ic( RFM $ uzzy _clus e ) , dis _ma ix)
380
381 ca (" silhoue e sco es : n")
382 ca ("k - means : " ,mean ( silhoue e _kmeans [ , 3]) , " n")
383 ca (" dbscan : " ,mean( silhoue e _dbscan [, 3] , na. m = TRUE ), " n")
384 ca ("hie a chical: ",mean( silhoue e _hie a chical[, 3]), " n")
385 ca ("gmm : ",mean( silhoue e _gmm [, 3]) , " n")
386 ca (" uzzy c - means : " ,mean( silhoue e _ uzzy [ , 3]) , " n")
387
388 calinski _ha abasz <- unc ion (da a, clus e _ ec o ) {
389 k<- leng h(unique(clus e _ ec o ))
390 i (k < 2) e u n(NA )
391 da a _ ma <- as .ma ix(da a)
392 n<- n ow (da a _ ma )
393 o e all_mean <- colMeans(da a_ ma )
394 W<- 0
395 B<- 0
396 o ( cl in unique(clus e _ ec o )) {
397 cl_indices <- which (clus e _ ec o == cl)
398 cl_ da a <- da a _ ma [cl_indices , , d op = FALSE ]
399 cl_mean <- colMeans ( cl_da a)
400 W<- W + sum ( owSums (( cl _da a - cl_mean) ^2) )
401 B<- B + n ow(cl_da a)* sum (( cl _mean - o e all_ mean ) ^2)
402 }
403 i (W == 0 || k == 1 || (n - k) == 0) e u n( NA)
404 (B /(k - 1)) /(W /(n - k))
405 }
406
407 ch_kmeans <- calinski _ha abasz ( RFM _no malized , RFM $kmeans_clus e )
408 ch_dbscan <- calinski _ha abasz ( RFM _no malized , RFM $dbscan_clus e )
409 ch_hie a chical <- calinski _ha abasz ( RFM _no malized , RFM $hie a chical_clus e )
410 ch_gmm <- calinski _ha abasz ( RFM _no malized , RFM $gmm _clus e )
411 ch_ uzzy <- calinski _ha abasz ( RFM _no malized , RFM $ uzzy _clus e )
412
413 ch_ esul s <- da a. ame (
414 me hod = c("k - means " ,"dbscan","hie a chical","gmm"," uzzy c - means " ),
415 calinski _ha abasz = c(ch_kmeans , ch_dbscan , ch_hie a chical , ch_gmm , ch_ uzzy )
416 )
417 p in (ch_ esul s)
72
5.1. RFM ANALYSIS, CLUSTERING CODE AND EVALUTATION BIBLIOGRAPHY
5.1.1 RFM 3D isualiza ion
Figu e 5.1: RFM K-Means Clus e ing (LOG)
Figu e 5.2: RFM DBSCAN Clus e ing (LOG)
73
5.1. RFM ANALYSIS, CLUSTERING CODE AND EVALUTATION BIBLIOGRAPHY
Figu e 5.3: RFM GMM Clus e ing (LOG)
Figu e 5.4: RFM Hie a chical Clus e ing (LOG)
74
5.2. CLV SEGMENTATION,CLUSTERING AND MODEL EVALUATION BIBLIOGRAPHY
Figu e 5.5: RFM Fuzzy Clus e ing (LOG)
5.2 CLV segmen a ion,clus e ing and model e alua ion
1# ######### load lib a ies ##########
2lib a y( e1071 )
3lib a y( dply )
4lib a y( lub ida e )
5lib a y(ggplo 2)
6lib a y(clus e )
7lib a y(dbscan)
8lib a y(mclus )
9lib a y( eshape2 )
10 lib a y( ggdend o )
11 lib a y( msb )
12 # ######### load and p ep ocess da a ##
13 da a <- ead.cs ("da a/da a .cs ")
14 da a <- da a %>%
15 mu a e ( In oiceDa e = as . Da e ( In oiceDa e , o ma ="%m/%d/%Y")) % >%
16 mu a e ( To alP ice = Quan i y *Uni P ice ) % >%
17 il e (!is.na( Cus ome ID ) , Quan i y > 0, Uni P ice > 0) %>%
18 g oup _by( Cus ome ID ) % >%
19 summa ise (
20 To alRe enue = sum( To alP ice ) ,
21 F equency = n_dis inc ( In oiceNo ) ,
22 A gT ansac ionValue = mean( To alP ice ) ,
23 Li espan = as.nume ic( di ime ( max( In oiceDa e ) , min ( In oiceDa e ) , uni s = " days "))
24 ) %>%
75
5.2. CLV SEGMENTATION,CLUSTERING AND MODEL EVALUATION BIBLIOGRAPHY
25 ung oup()
26
27 # ########## calcula e cl ##########
28 da a <- da a %>%
29 mu a e ( CLV = F equency *A gT ansac ionValue *Li espan )
30
31 # ######### no malize da a ##########
32 da a_no malized <- da a %>%
33 selec ( To alRe enue , F equency , A gT ansac ionValue , Li espan , CLV ) % >%
34 scale () % >%
35 as.da a. ame ()
36 ownames (da a_no malized ) <- da a$Cus ome ID
37
38 # ######### de ine s a is ics unc ions ##########
39 calcula e_s a is ics <- unc ion (da a , clus e _column ) {
40 da a %>%
41 g oup _by(!!sym ( clus e _column ) ) % >%
42 summa ise (
43 To Re enueMean = mean(To alRe enue),
44 FMean = mean( F equency ) ,
45 CLVMean = mean(CLV),
46 A gTMean = mean (A gT ansac ionValue),
47 Li espanMean = mean( Li espan ) ,
48 To SD = sd(To alRe enue),
49 FSD = sd ( F equency ),
50 CLVSD = sd(CLV),
51 A gTSD = sd(A gT ansac ionValue),
52 Li espanSD = sd ( Li espan ) ,
53 Size = n()
54 )
55 }
56
57 ##### elbow me hod ########
58 se .seed (123)
59 wss <- sapply(1:10 , unc ion (k) {
60 kmeans(da a_no malized , cen e s = k, ns a = 10) $ o . wi hinss
61 })
62 ggplo (da a. ame (k = 1:10 , wss = wss ) , aes (x = k, y = wss )) +
63 geom_line( size = 1, colo = " blue ") +
64 scale _x_con inuous ( b eaks = 1:10) +
65 labs( i le =" elbow me hod " , x = " numbe o clus e s " , y = " wi hin sum o squa es ") +
66 heme _minimal () +
67 heme (
68 panel . bo de = elemen _ ec ( colo = " black " , ill = NA , size = 1)
69 )
70
71 k_ alues <- 1:10
72
73 # p in elbow alues
76
5.2. CLV SEGMENTATION,CLUSTERING AND MODEL EVALUATION BIBLIOGRAPHY
74 elbow _ alues <- da a . ame (k = k_ alues, wss = wss)
75 p in ( elbow _ alues)
76
77 # ######### k - means ##########
78 k_op imal <- 4
79
80 kmeans_ esul <- kmeans(da a_no malized , cen e s = k_op imal , ns a = 10)
81 da a$kmeans_clus e <- as. ac o (kmeans_ esul $clus e )
82
83 # ######### isualize k- means ##########
84 ggplo (da a , aes (x = F equency , y = To alRe enue , colo = kmeans _clus e , size = CLV )) +
85 geom_poin ( alpha = 0.7) +
86 labs( i le ="k - means clus e ing ( cl )",x=" equency ", y = " o al e enue " , size = " cl
") +
87 heme _minimal()
88
89
90 # ######### k - means s a is ics ##########
91 kmeans_s a s <- calcula e _s a is ics ( da a,"kmeans_clus e ")
92 p in (kmeans_s a s )
93
94 # ######### hie a chical ##########
95 dis _ma ix <- dis (da a_no malized )
96 hc_ model <- hclus ( dis _ma ix , me hod = " wa d . D2")
97 da a$hie a chical_clus e <- cu ee(hc_ model , k = k_op imal)
98
99 # ######### dend og am ##########
100 plo (hc_ model , main = " hie a chical clus e ing dend og am ",
101 xlab = " index " , ylab = " dis ance ")
102 ec . hclus ( hc _model ,k=k_op imal , bo de = " ed ")
103
104 # ######### enhanced dend og am ##########
105 dend o <- as. dend og am ( hc_ model )
106 dend o_da a <- dend o_da a( dend o )
107
108 clus e _assignmen s <- cu ee(hc_ model , k = k_op imal)
109 labels _ d <- da a . ame ( label = ownames (da a_no malized ) ,
110 clus e = clus e _assignmen s ,
111 s ingsAsFac o s = FALSE)
112 labels _ d <- me ge (labels_d , dend o_da a$labels ,by =" label ")
113
114 ec _ da a <- agg ega e (x ~clus e , da a =labels _d ,
115 FUN = unc ion(x) c(min(x), max (x)))
116
117 ec _da a <- do.call( bind,lapply(1: n ow( ec _da a), unc ion (i) {
118 da a. ame (
119 clus e = ec _da a$clus e [i],
120 xmin = ec _da a$x[i, 1],
121 xmax = ec _da a$x[i, 2],
77
5.2. CLV SEGMENTATION,CLUSTERING AND MODEL EVALUATION BIBLIOGRAPHY
122 ymin = 0,
123 ymax = max(dend o_da a$segmen s $yend) /2
124 )
125 }))
126
127 ggplo () +
128 geom_segmen (da a = dend o_da a$segmen s ,
129 aes (x = x, y = y, xend = xend , yend = yend )) +
130 geom_ ec (da a = ec _da a ,
131 aes (xmin = xmin , xmax = xmax , ymin = ymin , ymax = ymax , ill = as. ac o (clus e
)),
132 alpha = 0.3) +
133 scale _ ill_manual ( name = "clus e ",
134 alues = c("# FF6666 " ,"#FFCC66"," #66 CC66 ","#66 CCCC ")) +
135 labs( i le =" hie a chical clus e ing dend og am ", x = "clien s", y = "heigh ") +
136 heme _minimal () +
137 heme ( axis. ex .x = elemen _blank () , axis. icks . x = elemen _blank () , legend. posi ion = "
igh ")
138
139 # ######### isualize hie a chical ##########
140 ggplo (da a , aes (x = F equency , y = To alRe enue , colo = as. ac o (hie a chical_clus e ),
size = CLV )) +
141 geom_poin ( alpha = 0.7) +
142 labs( i le =" hie a chical clus e ing ( cl )" ,x=" equency " , y = " o al e enue " , size =
"cl ", colo = "clus e ") +
143 heme _minimal()
144
145
146 # ######### hie a chical s a is ics ##########
147 hie a chical_s a s <- calcula e_s a is ics ( da a ,"hie a chical_clus e ")
148 p in (hie a chical_s a s )
149
150 # ##### dbscan ####
151 kNNdis plo <- unc ion (da a, k) {
152 dis ances <- kNNdis (da a, k = k)
153 dis ances <- so ( dis ances )
154 plo ( dis ances , ype = "l", main = "k- NN dis ance plo ",
155 xlab = " poin s so ed by dis ance " , ylab = "k -NN dis ance ")
156 }
157
158 kNNdis plo ( da a_no malized , k = 5)
159 abline( h = 0.6 , col =" ed ", lwd = 2)
160 dbscan_eps <- 0.6
161 dbscan_ esul <- dbscan(da a_no malized , eps = dbscan _eps , MinP s = 5)
162 da a$dbscan_clus e <- as. ac o (dbscan_ esul $clus e )
163
164 # ######### isualize dbscan ##########
165 ggplo (da a , aes (x = F equency , y = To alRe enue , colo = dbscan _clus e , size = CLV )) +
166 geom_poin ( alpha = 0.7) +
78