Sitemap
Deniz Can Oğuz

Deniz Can Oğuz

Invesment Analyst | Data Analyst | Data Scientist Check my website https://denizcanoguz.com.tr/

Potential Customer Revenue Calculation with Rule Based Classification

4 min readDec 14, 2021

--

Press enter or click to view image in full size

Hello there,

Our topic today is Potential Customer Revenue Calculation with Rule Based Classification.

So what does rule-based classification mean?

Rule-based classification is the processes we do to have a pattern and proceed programmatically to achieve the desired output according to our problem.

Okay we have a business problem.

Let’s take a look!

Business Problem:

A game company using some features of its customers new level-based customer definitions (persona) and these new customer definitions create segments according to these segments and create new How much is the average number of customers coming to the company? he wants to guess what he can gain.

For example, A 25-year-old male from Turkey who is an IOS user how much the user can earn on average is to be determined.

Our Dataset Story

The dataset contains the prices of the products sold by an international game company and some demographic information of the users who bought these products.

Get Deniz Can Oğuz’s stories in your inbox

Join Medium for free to get updates from this writer.

The data set consists of records created in each sales transaction. This means that the table is not deduplicated. In other words, a user with certain demographic characteristics may have shopped.

Our variables and the name of our dataset

  • persona.csv : dataset name
  • PRICE : Customer spend amount
  • SOURCE : The type of device the customer is connecting to
  • SEX : Customer’s gender
  • COUNTRY : Customer’s country
  • AGE : Customer’s age

Let’s see the steps to take

  • First appearance of our dataset
  • We can see that it consists of 5000 observations and 5 different variables
  • Target view of our dataset
  • We can see that the number of observations and variables are reduced as we intended

# We import our dataset and pandas library

# Let’s get to know our data set closely and view descriptive statistics with the help of a function

step2 output

# In COUNTRY, SOURCE, SEX, AGE breakdown
What are average earnings?

step3 output

# In order to see the output better, let’s sort it in descending order with the sort_value method and define it into a new variable.

step4 output

# Let’s reset Country Source Sex Age, which should actually be variable in the previous output but is in index form.

step5 output

# Let’s turn the age variable to a categorical variable and add it to our dataset as age_cat.

step6 output

# Let’s collect the Country, Source, Sex, Age_Cat variables from the previous output into a variable. Let’s set our variable to be named customers_leved_based.

step7 output

# Now let’s segment our dataset by price

step8 output
  • As we saw above, we reached our goal.

# Now is the time to estimate potential customer revenue

predict

# Above, Turkish android female 31–40 years old individual is expected to bring 41.83 units of income. This person is in segment A.

Thank you if you’ve read this far. I hope it was useful.

Resources and Thanks

# Follow the link for GitHub Repository doc.

--

--

Deniz Can Oğuz
Deniz Can Oğuz