Using Linear Regression to Predict Sales

  data-science, linear-regression, python

I am following this tutorial to create a prediction model for some sales data I have. However I am having some trouble understanding where to go next as the article sort of cuts short. At the end the Actual data vs prediction data is graphed. However, it does not go on to explain how to get estimates for your test data. I have 2 years worth of data(train), now I want to predict the first 3 months I have for this year(test) to see how close it is. I have the following code:

train_predictors = train.drop(['Entries'],axis=1)
train_target = train.drop(['year','label','month','MaxTemp'],axis=1)

test_predictors = test.drop(['Entries'],axis=1)
test_target = test.drop(['year','label','month','MaxTemp'],axis=1)

lr = LinearRegression(normalize=True)
lr.fit(train_predictors,train_target)

train_predictions=lr.predict(train_predictors)


plt.figure()
plt.figure(figsize=(10,10))


plt.scatter(train_target,train_predictions)
plt.xlabel("Actual",fontsize=18)
plt.ylabel("Predictions", fontsize=18)
plt.title("Actual vs Predictions",fontsize=18)


plt.plot(range(30000))

plt.axis("scaled")

display(plt.show())

I am trying to predict ‘Entries’. Can someone please explain what I can do now with my test data in order to compare these 3 months with predictions trained from the training data? Would be very much appreciated

Source: Python Questions

LEAVE A COMMENT