Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from sklearn import linear_model
- class MarketingCosts:
- # param marketing_expenditure list. Expenditure for each previous campaign.
- # param units_sold list. The number of units sold for each previous campaign.
- # param desired_units_sold int. Target number of units to sell in the new campaign.
- # returns float. Required amount of money to be invested.
- @staticmethod
- def desired_marketing_expenditure(marketing_expenditure, units_sold, desired_units_sold):
- return float (lin_regr.predict(np.array(60_000).reshape(-1, 1)) )
- mark_exp = np.array([300000, 200000, 400000, 300000, 100000]).reshape(-1, 1)
- units_s = np.array([60000, 50000, 90000, 80000, 30000]).reshape(-1, 1)
- lin_regr = linear_model.LinearRegression()
- lin_regr.fit(units_s,mark_exp)
- lin_regr.score(mark_exp, units_s)
- lin_regr.coef_
- lin_regr.intercept_
- lin_regr.predict(np.array(60_000).reshape(-1, 1))
- #For example, with the parameters below the function should return 250000.0.
- print(MarketingCosts.desired_marketing_expenditure(
- [300000, 200000, 400000, 300000, 100000],
- [60000, 50000, 90000, 80000, 30000],60000))
Add Comment
Please, Sign In to add comment