0

I wanted to predict the number of customers for the next 7 days. So Im going to use Linear Regression with Dates as my independent variable and # of Customers as my dependent variable. But I get weird values in the Coefficient and Intercept, that I doubt will result in good predictions.

This is my dataset from the csv file:

date,customers
1/1/2022,13
1/2/2022,23
1/3/2022,15
1/4/2022,45
1/5/2022,89
1/6/2022,34
1/7/2022,53

Here is my code:

data = pd.read_csv("data/Customers.csv", converters={"date": pd.Timestamp})

plt.scatter(data.date, data.customers)
plt.show()

linreg = linear_model.LinearRegression()
linreg.fit(data[['date']], data.customers)

#Coefficient
print(linreg.coef_)
#Intercept
print(linreg.intercept_)
#Prediction
print(linreg.coef_ * data.date[0].toordinal()) + linreg.intercept_)

These are the results:

Coefficient = [8.92857143e-14]
Intercept = -146501.71428571438
Prediction = [-146501.71428565]

0 Answers0