Skip to content

Instantly share code, notes, and snippets.

View raffg's full-sized avatar

Greg Rafferty raffg

View GitHub Profile
import re
text = ('0 13 127 196 245.0.0.1 255.255.255.255 this is text. '
'Here is an incorrectly formatted ip address: 135.223.452.446 '
'Here are some correct ones: 135.223.252.246, 0.0.0.1, 256.2.3.4, 14.46.34.65')
re.findall(r'\b(?:(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.){3}(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\b', text)
# ['245.0.0.1', '255.255.255.255', '135.223.252.246', '0.0.0.1', '14.46.34.65']
Dominant_Topic Topic_Keywords Num_Documents Percent_Documents
0.0 harry, ron, malfoy, gryffindor, slytherin, wood, hermione, back, team, broom 13 0.0677
1.0 harry, snape, hermione, black, lupin, ron, back, sirius, door, eye 17 0.0885
2.0 harry, wand, light, back, hand, foot, face, feel, head, move 24 0.125
3.0 dumbledore, harry, sirius, fudge, ministry, wizard, kreacher, sit, order, office 15 0.0781
4.0 ron, harry, hermione, mrs_weasley, ginny, bill, back, yeah, -PRON-, room 15 0.0781
5.0 harry, malfoy, ron, slughorn, ginny, riddle, potion, sir, lockhart, good 12 0.0625
6.0 harry, uncle_vernon, dudley, back, dursley, aunt_petunia, owl, letter, room, house 15 0.0781
7.0 hagrid, harry, hermione, moody, yeh, back, ron, ter, -PRON-, cedric 16 0.0833
8.0 ron, harry, hermione, professor, umbridge, neville, table, back, class, year 28 0.1458
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@raffg
raffg / mse.py
Last active August 12, 2018 17:44
SCRIPT_REAL(
'
import pandas as pd
import statsmodels.api as sm
dates = _arg1
passengers = _arg2
order_ar = min(_arg3)
order_i = min(_arg4)
order_ma = min(_arg5)
SCRIPT_REAL(
'
import pandas as pd
import statsmodels.api as sm
dates = _arg1
passengers = _arg2
order_ar = min(_arg3)
order_i = min(_arg4)
order_ma = min(_arg5)
Model Accuracy Precision Recall F1 Score
Gradient Boosting 95% 95% 95% 95%
Random Forest 94% 94% 95% 94%
AdaBoost 92% 92% 90% 91%
Logistic Regression 90% 90% 88% 89%
KNN 90% 91% 89% 90%
SVM 90% 90% 90% 90%
SVC 92% 92% 92% 92%
Multinomial Naive Bayes 84% 83% 82% 82%
import tweepy
import json
from time import sleep
credentials = json.load(open('.env/twitter_credentials.json'))
consumer_key = credentials['consumer_key']
consumer_secret = credentials['consumer_secret']
access_token = credentials['access_token']
access_token_secret = credentials['access_token_secret']
trumpstreamlistener = TrumpStreamListener()
start_stream()
def start_stream():
while True:
try:
trumpstream = tweepy.Stream(auth, trumpstreamlistener)
trumpstream.filter(follow=[realDonaldTrump])
except:
continue