Imagine you have an online shop and you have launched various promotions several times to attract customers.
To calculate the number of attracted users depending on the cost of the advertising campaign in the future, you want to build a linear regression model:
Find the value of the coefficient of the target dependency using the least squares method and the data below.
| Cost of an advertising campaign | Number of new customers |
| 4 | 2 |
| 6 | 2 |
| 8 | 3 |
| 10 | 5 |
| 12 | 5 |
Input values as NumPy arrays
import numpy as np
x = np.array([4, 6, 8, 10, 12])
y = np.array([2, 2, 3, 5, 5])