Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |