Skip to content

Instantly share code, notes, and snippets.

View gagejustins's full-sized avatar

Justin Gage gagejustins

  • New York City
View GitHub Profile
for epoch in range(numEpochs):
train(...) #Training code
accuracy = eval(...) #Evaluate accuracy
#If we've reached a new best accuracy
if accuracy > best_accuracy:
#Save model checkpoint
torch.save({'epoch': epoch,
'state_dict': model.state_dict(),
@gagejustins
gagejustins / followers.py
Last active April 5, 2018 13:35
Code for Twitter algorithm spotlight
import Algorithmia
input = {
"username": "elonmusk",
"auth": {
"app_key": "xxxxxxxxxx",
"app_secret": "xxxxxxxxxx",
"oauth_token": "xxxxxxxxxx",
"oauth_token_secret": "xxxxxxxxxx"
}
@gagejustins
gagejustins / call.py
Last active March 23, 2018 14:52
Code for sentiment analysis with Twitter demo
#Define your API Key from Algorithmia
apikey = 'YOUR_API_KEY'
#Initialize the Algorithmia client
client = Algorithmia.client(apikey)
#Create an instance of the RetrieveTweetsWithKeyword algorithm
algo = client.algo('diego/RetrieveTweetsWithKeyword/0.1.2')
#Call the algorithm for both of our keywords and store the results