[SOLVED] CS代写 FA72′, high=’#F46FEE’, guide = “legend”)

30 $

Marketing_Campaign_Simulation

Marketing Campaign Simulation Modeling¶

Copyright By PowCoder代写加微信 powcoder

We would like to model if a bank client would buy an investment product.

import pandas as pd
from plotnine.ggplot import *
!pip install plotnine
from plotnine.ggplot import *
from plotnine.geoms import geom_histogram
from plotnine.geoms import geom_vline
from plotnine.geoms import geom_point
from plotnine.scales import xlim
from plotnine.scales import ylim
from plotnine.scales import scale_color_gradient
%matplotlib inline

data = pd.read_csv(‘sale_probability.csv’)
ggplot(aes(x=’Sales probability’), data=pd.DataFrame({ ‘Sales probability’ : data[‘probabilities’] }))
+ geom_histogram(binwidth=0.02, color=’darkcyan’, fill=”white”)
+ geom_vline(xintercept=[0.30, 0.70], linetype=’dashed’, color=”indigo”)
+ ylim(0, 215000)

data = pd.read_csv(‘sale_probability.csv’)
ggplot(aes(x=’Sales probability’), data=pd.DataFrame({ ‘Sales probability’ : data[‘probabilities’] }))
+ geom_histogram(binwidth=0.02, color=’darkcyan’, fill=”white”)
+ geom_vline(xintercept=[0.30, 0.70], linetype=’dashed’, color=”indigo”)
+ ylim(0, 800)
+ xlim(0.25, 1)

C:Usersromananaconda3libsite-packagesplotninelayer.py:324: PlotnineWarning: stat_bin : Removed 497457 rows containing non-finite values.
C:Usersromananaconda3libsite-packagesplotninelayer.py:401: PlotnineWarning: geom_histogram : Removed 1 rows containing missing values.

We need to select a group of clients to be contacted, e.g., by phone, about the investment product. Our goal is to maximize sales (number of clients that buy the product) and minimize cost of contact (cost of contacting the client, e.g., salary of client representatives).

To achieve our goal we can simulate marketing campaign for the sales using probabilities of sales for each client that we have in the dataset. Simulation modeling would allow us to select parameters ${rm min_probability}$ and ${rm max_probability}$that give us a list of clients that need to be contacted.

To enhance our model we can try compute if phone call to a client would increase or decrease a probability of sale (sales uplift) if we have data about previous contacts with clients. As we do not have it, we would choose a simple model of “uplift” – probability of sale will increase by 10% if a clients gets a call from the client representative.

Profit function from phone calls is:
$$profit=N_{sales}*avg(income_{sale})-N_{contacts}*avg(costs_{contact})$$
To enhace our simulation model we may use more complex model for costs of contact, e.g., fixed cost plus variable cost based on duration of phone calls.

import numpy.random as rnd
import numpy as np

result = []
def monte_carlo_coin(probability):
r = rnd.uniform()
return int(r < probability)def profit(n_sales, n_contacts):avg_income_sale = 10.0avg_costs_contact = 2.0return n_sales*avg_income_sale – n_contacts*avg_costs_contactfor min_probability in np.arange(0.0,0.9,0.1):for max_probability in np.arange(min_probability+0.1,1.0,0.1):target_group = data.probabilities.between(min_probability, max_probability)data_after_contact = data.copy()data_after_contact.loc[target_group, ‘probabilities’] = data.loc[target_group].probabilities + 0.1for _ in range(10):# simulationdata_after_contact[‘sales’] = data_after_contact[‘probabilities’].apply(monte_carlo_coin)sales = data_after_contact[‘sales’].sum(axis=0)calls = target_group.sum(axis=0)prof += profit(sales, calls)prof /= 10result.append((min_probability, max_probability, sales, calls, prof))best_results = sorted(result, key=lambda x: x[4])best_results[-1] (0.5, 0.6, 18746, 138, 187388.0) best_results[-5::1] [(0.4, 0.6, 18797, 439, 186614.0), (0.7000000000000001, 0.9, 18660, 40, 186675.0), (0.6000000000000001, 0.8, 18613, 77, 186676.0), (0.8, 0.9, 18871, 12, 187296.0), (0.5, 0.6, 18746, 138, 187388.0)]As a result we get a target group of clients to contact. The target group has middle ranges of probability values, namely 0.5 to 0.9 (smallest ${rm min_probability}$ and largest ${rm max_probability}$ among three best results) as clients with small probability values would not buy the product even if they get a phone call, while clients with high probability fo sale already decided to buy a product and the phone call would not help. vis = pd.DataFrame(result, columns=[‘Minimal probability’, ‘Maximum probability’, ‘No of sales’, ‘No of calls’, ‘Profit’])print (scale_color_gradient)ggplot(vis[vis[“Minimal probability”]>0.1], aes(x=’Minimal probability’, y=’Maximum probability’, color=’Profit’)) +
geom_point(size=3) +
scale_color_gradient(low=’blue’, high=’red’)

ggplot(vis[vis[“Minimal probability”]>0.3], aes(x=’Minimal probability’, y=’Maximum probability’, color=’Profit’)) +
geom_point(size=5) +
scale_color_gradient(low=’#E1FA72′, high=’#F46FEE’, guide = “legend”)

程序代写 CS代考加微信: powcoder QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS代写 FA72′, high=’#F46FEE’, guide = “legend”)
30 $