Skip to content

Instantly share code, notes, and snippets.

from __future__ import print_function
import numpy as np
np.random.seed(1337) # for reproducibility
from keras.preprocessing import sequence
from keras.models import Sequential
from keras.layers import Dense, Flatten
from keras.layers import Embedding
from keras.layers import AveragePooling1D
from keras.datasets import imdb
library(XML)
library(uuid)
library(stringr)
library(plyr)
library(reshape2)
library(ggplot2)
f <- "https://raw.githubusercontent.com/chris-taylor/USElection/master/data/electoral-college-votes.csv"
electoral.college <- read.csv(f, header=FALSE)
names(electoral.college) <- c("state", "electoral_votes")
library(plyr)
library(XML)
library(uuid)
library(reshape2)
results <- ldply(states, function(state) {
url <- "http://www.electionprojection.com/latest-polls/%s-presidential-polls-trump-vs-clinton-vs-johnson-vs-stein.php"
state.fmt <- gsub(" ", "-", tolower(state))
url.state <- sprintf(url, state.fmt)
from yhat import Yhat, YhatModel
import numpy as np
class SplitTestExample(YhatModel):
def execute(self, data):
# randomly select model to use. `p` defines the split percentage
endpoints = ["ModelA", "ModelB"]
endpoint = np.random.choice(endpoints, p=[0.2, 0.8])
# make prediction to a "sub-model". this will give you back the full API response
import mxnet as mx
import numpy as np
import cv2
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
# Variables are place holders for input arrays. We give each variable a unique name.
data = mx.symbol.Variable('data')
import networkx as nx
from yhat import YhatModel, Yhat
graphdict = {
"Houston": ["Austin", "Dallas", "Oklahoma City"],
"Austin": ["New Orleans", "Dallas"],
"New Orleans": ["Austin"],
"Dallas": ["New York"],
"Oklahoma City": ["Austin", "Dallas"],
import pandas as pd
from ggplot import *
diamonds.head()
columns = ['cut', 'color', 'clarity', 'carat', 'price']
diamonds[columns].groupby(['cut', 'clarity', 'color']).mean().reset_index()
import numpy as np
ggplot(mtcars, aes(x='mpg')) + geom_histogram() + \
theme(axis_text=element_text(size=20, color='green'), x_axis_text=element_text(angle=45))
ggplot(df, aes(x='date', y='pd.rolling_mean(value, 12)')) + \
geom_line() + \
facet_wrap("variable", scales="free")
ggplot(meat, aes(x='date', y='pd.rolling_mean(beef, 12)')) + \
geom_line()