Blog

Customer Segmentation using Python

Segmentation of Prospects based on department using Python

๐‚๐จ๐๐ž ๐ข๐ฌ ๐๐ข๐ซ๐ญ ๐œ๐ก๐ž๐š๐ฉ, ๐ง๐จ๐ฐ.

LLMs are responsible and there is no looking back.

The last time I was coding for a living was 20 years back and it was a long painful process of learning the skill / language, applying and getting proficient in it.

But now things are different and let me explain with a use case.

As a marketer we get a lot of lead form fills. Some of the fields are free text like designation.

If I want to segment this list based on departments, I face an uphill task as filters donโ€™t work. Key challenges include

โ†ณ Spelling mistakes
โ†ณ Short and Long form of same designation
โ†ณ Special characters

To solve this, I now enter the challenge / problem statement into LLM and ask for a solution with code.

๐•๐จ๐ข๐ฅ๐š, I have the code which I can just copy and paste in apps like Jupyter notebook. I only need to know the basics of programming with a good understanding of input data and expected result.

I applied the same process, and got a result which was 85-90% accurate. Had I done it manually, I would have ended up spending 3-4 additional hrs.

LLM gave me 3 options to solve the problem.

โ†ณ Excel formula
โ†ณ Python program
โ†ณ NLP (Natural Language Programming)

I tried excel first but soon realized that excel cannot manage to many conditional statements and I dropped it.

Being an AI / ML enthusiast, I tried to implement the NLP but soon was disappointed with the result. Maybe I chose the wrong model and hence I dropped that too.

I then executed the Python code on ๐‰๐ฎ๐ฉ๐ฒ๐ญ๐ž๐ซ ๐ง๐จ๐ญ๐ž๐›๐จ๐จ๐ค.

Donโ€™t get me wrong as it didnโ€™t give me the exact output I was expecting but then I turned back to LLM and it gave me the required changes which I then implemented.

Finally, I got the desired output and was happy with the result.

Knowing the near accurate department wise segmentation of my prospects will help me target them better with my marketing message.

Attaching the code for reference. I donโ€™t claim it is the best code written but it got the job done.

When asked whether programming will remain a helpful skill in the age of generative AI prompts, Huang said, “๐˜ ๐˜ต๐˜ฉ๐˜ช๐˜ฏ๐˜ฌ ๐˜ต๐˜ฉ๐˜ข๐˜ต ๐˜ฑ๐˜ฆ๐˜ฐ๐˜ฑ๐˜ญ๐˜ฆ ๐˜ฐ๐˜ถ๐˜จ๐˜ฉ๐˜ต ๐˜ต๐˜ฐ ๐˜ญ๐˜ฆ๐˜ข๐˜ณ๐˜ฏ ๐˜ข๐˜ญ๐˜ญ ๐˜ฌ๐˜ช๐˜ฏ๐˜ฅ๐˜ด ๐˜ฐ๐˜ง ๐˜ด๐˜ฌ๐˜ช๐˜ญ๐˜ญ๐˜ด,” However, โ€œ๐˜ฑ๐˜ณ๐˜ฐ๐˜จ๐˜ณ๐˜ข๐˜ฎ๐˜ฎ๐˜ช๐˜ฏ๐˜จ ๐˜ช๐˜ด ๐˜ฏ๐˜ฐ๐˜ต ๐˜จ๐˜ฐ๐˜ช๐˜ฏ๐˜จ ๐˜ต๐˜ฐ ๐˜ฃ๐˜ฆ ๐˜ฆ๐˜ด๐˜ด๐˜ฆ๐˜ฏ๐˜ต๐˜ช๐˜ข๐˜ญ ๐˜ง๐˜ฐ๐˜ณ ๐˜บ๐˜ฐ๐˜ถ ๐˜ต๐˜ฐ ๐˜ฃ๐˜ฆ ๐˜ข ๐˜ด๐˜ถ๐˜ค๐˜ค๐˜ฆ๐˜ด๐˜ด๐˜ง๐˜ถ๐˜ญ ๐˜ฑ๐˜ฆ๐˜ณ๐˜ด๐˜ฐ๐˜ฏ.”

Should marketers learn coding in the Age of AI? Comment below.

p.s. Drop your email in the followit box to receive my latest blog. We can also stay connected on various social media platforms, just click the links to follow.


# Segmentation of Prospects based on department using Python
import pandas as pd
# Load the data
df = pd.read_csv("designations.csv")

# Define classification functions
def classify_department(designation):
if “finance” in designation.lower() or “cfo” in designation.lower() or “accounts” in designation.lower() or “controller” in designation.lower() or “tax” in designation.lower() :
return “Finance / Accounts”
elif “hr” in designation.lower() or “human resource” in designation.lower():
return “HR”
elif “sales” in designation.lower():
return “Sales”
elif “legal” in designation.lower() or “counsel” in designation.lower():
return “Legal”
elif “secretarial” in designation.lower() or “cs” in designation.lower() or “compliance” in designation.lower() or “secretary” in designation.lower() :
return “Secretarial”
elif “information” in designation.lower() or “cio” in designation.lower() or “it” in designation.lower() or “cto” in designation.lower() :
return “IT”
elif “procurement” in designation.lower():
return “Procurement”
elif “auditor” in designation.lower():
return “Audit”
else:
return “Other”

# Apply classification functions
df[‘Department’] = df[‘Designation’].apply(classify_department)
#df[‘Seniority’] = df[‘Designation’].apply(classify_seniority)

# Save the result
df.to_csv(“classified_data.csv”, index=False)

 

Leave a Comment

Your email address will not be published. Required fields are marked *