0

I'm trying to study customers behavior. Basically, I have information on customer's loyalty points activities data (e.g. how many points they have earned, how many points they have used, how recent they have used/earn points etc). I'm using R to conduct this analysis

I'm just wondering how should I go about segmenting customers based on the above information? I'm trying to apply the RFM concept then use K-means to segment my customers(although I have a few more variables than just R,F,M , as i have recency,frequency and monetary on both points earn and use, as well as other ratios and metrics) . Is this a good way to do this?

Essentially I have two objectives: 1. To segment customers 2. Via segmenting customers, identify customers behavior(e.g.customers who spend all of their points before churning), provided that segmentation is the right method for such task?

Clustering <- kmeans(RFM_Values4,centers = 10)

Please enlighten me, need some guidance on the best methods to tackle such problems.

IV_Z
  • 31
  • 6
  • Please fix your indentation so that it is easier for us to help you. – Rob Murray Dec 08 '15 at 10:51
  • @R.Murray , thanks I copied straight from Python shell so the indentation should be ok?? – IV_Z Dec 08 '15 at 11:09
  • I'm pretty sure the whole `with` structure should be indented so that it is part of the `while True` loop. Copying straight across from IDLE often doesn't work properly. – Rob Murray Dec 08 '15 at 11:11
  • @R.Murray, unfortunately i don't have an editor yet.will get one soon. Are you able to tell where it went wrong? – IV_Z Dec 08 '15 at 11:24
  • Now you have a while true and no way to break out of it. Breaks only stop the smallest level of for/while available, in order to break out of several levels of for/while please check this question http://stackoverflow.com/questions/189645/how-to-break-out-of-multiple-loops-in-python – Noel Segura Meraz Dec 08 '15 at 11:50
  • without the while true i'm afraid i wont be able to loop though the existing elements. – IV_Z Dec 08 '15 at 12:23
  • @IV_Z, but you need to define a case to stop the loop, otherwise it will be infinite – Noel Segura Meraz Dec 08 '15 at 13:14
  • you loop through the list of elements by `for sub_list in (driver.find_elements...` You don't need `While` loop at all – Andersson Dec 08 '15 at 14:38

1 Answers1

0

Your attempts is always less then 5 because there is no variable increment. So your loop is infinite

Andersson
  • 51,635
  • 17
  • 77
  • 129
  • thanks. I tried removing the attempts but the loop is still infinite if one of the element im tring to locate is not present: e.g. if the following element does not exist the program will just keep printing element 1 and 2 non stop elem = driver.find_element_by_xpath("//*[@id='wrapper']/div[2]/div[2]/div/div[2]/div[1]/div[3]/div[1]/div[2]/div/div[2]/div/div[2]/div/div[3]") – IV_Z Dec 08 '15 at 11:36
  • This xpath is very-very bad:) You should never use absolute xpaths – Andersson Dec 08 '15 at 11:53
  • unfortunately the site has thousands of sub/sub div element at child level making any element find function not so user friendly – IV_Z Dec 08 '15 at 12:23
  • so use just a child locators – Andersson Dec 08 '15 at 12:24
  • sorry I have only been using python and programming for 3 weeks I need some time for some research :) – IV_Z Dec 08 '15 at 12:50