Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created January 26, 2021 08:41
Show Gist options
  • Save amankharwal/eec01dbe9fad1aa5dfd727da414957a1 to your computer and use it in GitHub Desktop.
Save amankharwal/eec01dbe9fad1aa5dfd727da414957a1 to your computer and use it in GitHub Desktop.
def PredictionsWithConstantFollowers(model, followerCount, scaller, maxVal):
followers = followerCount * np.ones(24)
hours = np.arange(1, 25)
# defining vector
featureVector = np.zeros((24, 2))
featureVector[:, 0] = followers
featureVector [:, 1] = hours
# doing scalling
featureVector = scaller.transform(featureVector)
predictions = model.predict(featureVector)
predictions = (maxValLikes * predictions).astype('int')
plt.figure(figsize= (10, 10))
plt.plot(hours, predictions)
plt.style.use('seaborn-whitegrid')
plt.scatter(hours, predictions, color = 'g')
plt.grid(True)
plt.xlabel('hours since posted')
plt.ylabel('Likes')
plt.title('Likes progression with ' + str(followerCount) +' followers')
plt.show()
PredictionsWithConstantFollowers(gbr, 100, stdSc, maxValLikes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment