Skip to content

Instantly share code, notes, and snippets.

View wassname's full-sized avatar
🙃

Michael J Clark wassname

🙃
View GitHub Profile
@wassname
wassname / visualising keras.ipynb
Created September 9, 2016 03:03
Visualising keras weights and output using matplotlib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wassname
wassname / classification_report_parse.py
Last active March 10, 2017 04:25
Digitize scikit-learn's classification_report
from io import StringIO
import pandas as pd
import numpy as np
import sklearn
def parse_classification_report(classification_report):
"""Parses sklearn classification report into a pandas dataframe."""
return pd.read_fwf(StringIO(classification_report),lineterminator='\n', index_col=0, colspecs=[(0,12),(12,22),(22,32),(32,42),(42,52)]).dropna()
target_names['leak','no leak']
@wassname
wassname / main.ipynb
Created March 28, 2017 00:05
Makehuman variational auto-encoder
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wassname
wassname / natural-webpack.js
Created April 3, 2016 09:16
Importing natural into webpack (the node nlp toolkit)
/*
Importing natural into webpack (the node nlp toolkit)
This is just copy of natural's index.js with some exports commented out.
This way it works in webpack, however I haven't full tested it.
*/
exports.SoundEx = require('natural/lib/natural/phonetics/soundex');
exports.Metaphone = require('natural/lib/natural/phonetics/metaphone');
exports.DoubleMetaphone = require('natural/lib/natural/phonetics/double_metaphone');
@wassname
wassname / TrainIntervalLoggerTQDMNotebook.py
Last active June 30, 2017 15:04
keras-rl's TrainIntervalLogger but using tqdm for jupyter notebook
from rl.callbacks import TrainIntervalLogger
from tqdm import tqdm_notebook
import timeit
class TrainIntervalLoggerTQDMNotebook(TrainIntervalLogger):
"""TrainIntervalLogger using tqdm_notebook for jupyter-notebook."""
def reset(self):
self.interval_start = timeit.default_timer()
self.metrics = []
self.infos = []
@wassname
wassname / pixels to pong annotated.ipynb
Created July 13, 2017 13:54
Pixels to pong annotated for deep learning group - 2017 July 13
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wassname
wassname / TrainIntervalLoggerTQDMNotebook.py
Created July 18, 2017 08:37
logging callback for keras-rl using tqdm_notebook for jupyter-notebook
from rl.callbacks import Callback
from rl.callbacks import TrainIntervalLogger
from keras import backend as K
import warnings
from tqdm import tqdm_notebook
import timeit
import numpy as np
class TrainIntervalLoggerTQDMNotebook(TrainIntervalLogger):
"""TrainIntervalLogger for keras-rl using tqdm_notebook for jupyter-notebook."""
@wassname
wassname / subimshow.py
Last active July 25, 2017 02:59
imshow a panel of images
import numpy as np
from matplotlib import pyplot as plt
def subimshow(image, title=''):
"""
Show each band seperately.
The shape si a square or rectangle of images
image: array of shape (channel, height, width)
@wassname
wassname / multi_image_datagenerator.py
Last active August 19, 2017 14:45
mod to Allow keras's ImageDataGenerator to have multiple channels instead of just 1,3,4. Tested with keras>=1.2.2
"""
mod to Allow the ImageDataGenerator to have multiple channels instead of just 1,3,4
modified from https://github.com/fchollet/keras/blob/master/keras/preprocessing/image.py
"""
from keras.preprocessing.image import Iterator
from keras import backend as K
from keras.preprocessing.image import ImageDataGenerator as _ImageDataGenerator
from path import Path