Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
#!/bin/python | |
''' | |
Usage: | |
python downsample.py [offset+]amount | |
Examples: | |
cat super_big.csv | python downsample.py 1+4 > big_divided_by_4.csv | |
cat data.csv | python downsample.py 2 > data_halved.csv | |
''' |
This file contains hidden or 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
# Create an array of Multinomial Naive Bayes | |
multi_class = [MultinomialNB(alpha=factor) for factor in np.concatenate((np.arange(0, 3.1, 0.1), [5, 10]))] | |
for nb in multi_class: | |
nb.fit(X_train, y_train) | |
import seaborn as sns | |
from sklearn.metrics import precision_recall_curve |
This file contains hidden or 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
#!/usr/bin/env python | |
""" | |
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction. | |
""" | |
from __future__ import print_function, division | |
import numpy as np | |
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten | |
from keras.models import Sequential |
This file contains hidden or 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
# R code to produce a simulated dataset for an experiment on a made up insect. | |
# Measures include sex, body length, thorax width, number of thoracic bristles and some measure of aggression behaviour. | |
# Also there is exposure to some treatment stimulus/drug. | |
# This simulation uses Copulas to generate correlated variables from binomial, Gaussian and Poisson distributions | |
require(copula) | |
set.seed(1888) | |
n <- 1000 |
This file contains hidden or 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
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
import numpy as np | |
import cPickle as pickle | |
import gym | |
# hyperparameters | |
H = 200 # number of hidden layer neurons | |
batch_size = 10 # every how many episodes to do a param update? | |
learning_rate = 1e-4 | |
gamma = 0.99 # discount factor for reward |
This file contains hidden or 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
#How to download streaming video | |
Streaming just means a download that they don't want you to keep. But Chrome's developer tools make it easy to access what's really going on under the hood. | |
##Open Developer Tools | |
From the page where you want to download some things, go into your chrome menu to open the developer tools. You can either: | |
1. (On a mac): Command-option-J | |
2. (On a PC): Control-alt-J |
This file contains hidden or 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 keras.datasets import imdb | |
from keras.preprocessing.sequence import pad_sequences | |
from keras.models import Sequential | |
from keras.layers import containers | |
from keras.layers.noise import GaussianNoise | |
from keras.layers.core import Dense, AutoEncoder | |
from keras.utils import np_utils | |
from sklearn.metrics import (precision_score, recall_score, |
NewerOlder