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 __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 |
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
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") |
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
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) |
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 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 |
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 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') |
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 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"], |
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 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 |
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
ggplot(mtcars, aes(x='mpg')) + geom_histogram() + \ | |
theme(axis_text=element_text(size=20, color='green'), x_axis_text=element_text(angle=45)) |
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
ggplot(df, aes(x='date', y='pd.rolling_mean(value, 12)')) + \ | |
geom_line() + \ | |
facet_wrap("variable", scales="free") |
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
ggplot(meat, aes(x='date', y='pd.rolling_mean(beef, 12)')) + \ | |
geom_line() |