SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. from sklearn import linear_model
  3.  
  4. class MarketingCosts:
  5.  
  6.     # param marketing_expenditure list. Expenditure for each previous campaign.
  7.     # param units_sold list. The number of units sold for each previous campaign.
  8.     # param desired_units_sold int. Target number of units to sell in the new campaign.
  9.     # returns float. Required amount of money to be invested.
  10.     @staticmethod
  11.     def desired_marketing_expenditure(marketing_expenditure, units_sold, desired_units_sold):
  12.         mar_exp=np.asarray(marketing_expenditure).reshape(-1,1)
  13.         u_sold=np.asarray(units_sold).reshape(-1,1)
  14.         regr = linear_model.LinearRegression()
  15.         regr.fit(u_sold, mar_exp)
  16.         pred=float(regr.predict(desired_units_sold))
  17.         return round(pred,1)  
  18.        
  19.        
  20.  
  21. #For example, with the parameters below the function should return 250000.0.
  22. print(MarketingCosts.desired_marketing_expenditure(
  23.     [300000, 200000, 400000, 300000, 100000],
  24.     [60000, 50000, 90000, 80000, 30000],
  25.     60000))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top