Guest User

Untitled

a guest
Jan 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import numpy as np
  2. from sklearn import linear_model
  3. from sklearn.linear_model import LinearRegression
  4.  
  5. class MarketingCosts:
  6.  
  7. # param marketing_expenditure list. Expenditure for each previous campaign.
  8. # param units_sold list. The number of units sold for each previous campaign.
  9. # param desired_units_sold int. Target number of units to sell in the new campaign.
  10. # returns float. Required amount of money to be invested.
  11. @staticmethod
  12. def desired_marketing_expenditure(marketing_expenditure, units_sold, desired_units_sold):
  13. X= []
  14. Y = []
  15. for k in units_sold:
  16. X.append([k])
  17. X = np.array(X)
  18. Y=np.array(marketing_expenditure)
  19. reg = LinearRegression().fit(X, Y)
  20. hasil = reg.predict(np.array(desired_units_sold))
  21. return hasil
  22.  
  23.  
  24. #For example, with the parameters below the function should return 250000.0.
  25. print(MarketingCosts.desired_marketing_expenditure(
  26. [300000, 200000, 400000, 300000, 100000],
  27. [60000, 50000, 90000, 80000, 30000],
  28. 60000))
Add Comment
Please, Sign In to add comment