Skip to content

Instantly share code, notes, and snippets.

View limitpointinf0's full-sized avatar
:atom:
Experimenting

Limitpointinf0 limitpointinf0

:atom:
Experimenting
View GitHub Profile
@limitpointinf0
limitpointinf0 / nn.py
Last active April 25, 2018 21:35
Easy Keras Models and Plotting
import numpy as np
import tensorflow
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.utils import to_categorical
from keras.callbacks import EarlyStopping
from keras.optimizers import SGD, Adam
from keras.callbacks import History
from sklearn.model_selection import train_test_split
@limitpointinf0
limitpointinf0 / mmtest.py
Last active April 25, 2018 23:06
Multi-Model Testing with Sci-kit Learn
import os
import itertools
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
import matplotlib.pyplot as plt
def Multi_KNN_Class(X, y, test_s=0.1, neighbors=[1,2,3], p_val=[1,2], leaf=[30], iterations=20, fig_s=(15,9), path=os.getcwd(), plot=False, verbose=True):
"""test out all combinations of hyperparameters to find the best model configuration. Returns statistics for mean and standard
deviation of accuracy over the amount of iterations for each hyperparameter settings."""
mu_sigma_list = []
@limitpointinf0
limitpointinf0 / scrape_assist.py
Created April 27, 2018 04:39
Scrape Assistant
from bs4 import BeautifulSoup
import sys
import requests
import re
import string
import time
import random
import urllib
import traceback
@limitpointinf0
limitpointinf0 / tic_tac.py
Last active April 28, 2018 06:07
Random Tic Tac Toe Game Simulator
"""
This script was created for the purpose of machine learning on tic-tac-toe.
You may extend the board to any square size.
the script will write to two csv files: one for predictors and the other for target
Special predictor Values:
dd - filled space from either player winning to pad the empty spaces
Target Variable Values:
@limitpointinf0
limitpointinf0 / lstm_nlp.py
Last active May 8, 2018 04:05
Simple LSTM for NLP
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import string
import re
from nltk.tokenize import word_tokenize
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, LSTM
from keras.utils import to_categorical
from keras.callbacks import EarlyStopping
@limitpointinf0
limitpointinf0 / easy_pltly.py
Last active May 4, 2018 19:02
Easy Plotly
import plotly as py
import plotly.graph_objs as go
import numpy as np
#py.tools.set_credentials_file(username='user_name', api_key='api_key')
py.offline.init_notebook_mode(connected=True)
def make_trace(x, y, mode='markers', pltname=None, shape='spline'):
trace = go.Scatter(x = x, y = y, mode = mode, name = pltname, line = dict(shape=shape))
return trace
@limitpointinf0
limitpointinf0 / img_cnn.py
Created May 6, 2018 01:27
Image Classification with Keras CNN
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import os
from PIL import Image
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from skimage import transform
from sklearn.model_selection import train_test_split
import traceback
from sklearn.utils import shuffle
@limitpointinf0
limitpointinf0 / eda_text.py
Created May 7, 2018 02:24
Text Cleaning and EDA
"""The following script contains two functions. One for creating a wordcloud from a string. The second is for cleaning text found
in a dataframe column."""
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import os
from wordcloud import WordCloud, STOPWORDS
import string
import matplotlib.pyplot as plt
from nltk.corpus import stopwords
@limitpointinf0
limitpointinf0 / send_sms.py
Last active June 9, 2018 02:54
Send an SMS using Twilio API
# Import the module
import subprocess
class TextMessage():
def __init__(self, url, from_, message, creds, number):
self.tool = 'curl'
self.url = url
self.from_ = 'From=%s' % from_
self.message = 'Body=%s' % message
@limitpointinf0
limitpointinf0 / tracker.py
Last active June 16, 2018 04:48
Track device presence on your LAN. (requires arp-scan)
import os
from datetime import datetime, timedelta
import time
import subprocess
import re
if os.geteuid() != 0:
exit("You need to have root privileges to run this script.")
class DeviceTracker():