#!/usr/bin/env python # coding: utf-8 # ### Business Case: Pharmaceutical Advertising Optimization # # ** Challenge:** Nova, A pharmaceutical company, lacks bsuiness insghts on how their advertising spending influences the sales, from their data. Nova needs to allocate its budget wisely to maximize sales but lacks insight into the most effective strategy. # # **Objectives:** # - **Data Analysis:** Analyze historical advertising costs and sales data. # - **Correlation Modeling:** Establish the relationship between advertising spend and sales. # - **Budget Optimization:** Develop a model to allocate the advertising budget for optimal sales outcomes. # # **Strategy:** # - **Data Collection:** Gather historical advertising and sales data. # - **Analysis:** Identify patterns and correlations in the data. # - **Modeling:** Create a predictive model to determine the best budget allocation. # - **Optimization:** Use the model to optimize advertising spending for maximum sales impact. # # **Expected Outcomes:** # - **Informed Decisions:** Gain insights into the advertising-sales relationship. # - **Efficient Budgeting:** Optimize budget allocation for maximum sales. # - **Risk Reduction:** Mitigate uncertainties associated with budget decisions. # # **Benefits:** # - **Improved ROI:** Maximize returns on advertising investments. # - **Strategic Planning:** Align budget with long-term sales goals. # - **Competitive Advantage:** Gain an edge through data-driven advertising strategies. # In[2]: import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # In[3]: df = pd.read_csv(r"C:\Users\Teni\Desktop\Advertising.csv") # data for year 2022 and 2023 # In[4]: df.head(10) # This record shows us how much Nova has spent on TV, radio and newspaper in the year 2023. # As well as the total_sales made at each Ad attempt. # In[5]: # To help us determine how much has been spent on Ad in general and the resultant sales, an additional column-summing up total costs- with will be created df['total_AdSpend'] = df['Instagram'] + df['Youtube'] + df['Podcasts'] # In[6]: df # In[7]: plt.figure(figsize=[10, 6], dpi= 200) sns.scatterplot(data=df, x = 'total_AdSpend', y = 'generated_sales'); # This shows there's an existing positive Linear relationship between the total cost spent on Ads and the sales generated by Nova # **Defining the Coefficient Variable** # In[11]: X = df['total_AdSpend'] y = df['generated_sales'] # X is the Feature (Independent Variable) # y is the Label (Dependent Variable) # In[12]: # From the Linear Regression equationy = mx + b # We using the deg 1 because the relationshop is linear np.polyfit(X, y, deg=1) # This form the coefficients for the m and b # **Hypothetical Determinant** # In[37]: projected_cost = np.linspace(2, 340, 300) # Here we have an array of 300 numbers spaced from 2 to 340. # In[38]: # Using the y = mx + b projected_sales = 0.04868788*projected_cost + 4.24302822 # In[39]: Q3_AdDeterminant = pd.DataFrame({'Ad_costs': projected_cost, 'Projected_sales': projected_sales}) Q3_AdDeterminant # In[40]: sns.scatterplot(data=df, x = 'total_AdSpend', y = 'generated_sales'); plt.plot(projected_cost, projected_sales, color ='purple'); # **If we had an Ad budget of 10k, what'd our projected sales value be?** # In[41]: spend = 10 sales = 0.04868788*spend + 4.24302822 sales # In[ ]: # In[ ]: