Skip to content

Instantly share code, notes, and snippets.

@Joshuaek
Last active November 14, 2017 06:22
Show Gist options
  • Save Joshuaek/7c0e1188601ebb63b8f3f554eaae2856 to your computer and use it in GitHub Desktop.
Save Joshuaek/7c0e1188601ebb63b8f3f554eaae2856 to your computer and use it in GitHub Desktop.
inputs = []
outputs = []
for tweet in tweets:
sentence = prepareSentence(tweet["text"])
# create our bag of words array
bag = toBOW(sentence, final_words)
inputs.append(bag)
#Calculate a score, 1 if any engagement, 0 if none
score = min(tweet["likes"] + tweet["retweets"],1)
outputs.append(score)
#Define and train the network
nnet = MLPRegressor(activation='relu', alpha=0.0001, hidden_layer_sizes=(int(len(final_words)*0.5),int(len(final_words)*0.25)),solver='adam', max_iter=400)
nnet.fit(inputs, outputs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment