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 tensorflow as tf | |
| from tensorflow.python.ops.rnn_cell import RNNCell | |
| from tensorflow.python.ops import variable_scope as vs | |
| from tensorflow.python.util import nest | |
| class ResidualRNNCell(RNNCell): | |
| """RNN cell composed sequentially of multiple simple cells with residual connection.""" | |
| def __init__(self, cells, state_is_tuple=False): |
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
| """ From: http://danielhnyk.cz/predicting-sequences-vectors-keras-using-rnn-lstm/ """ | |
| from keras.models import Sequential | |
| from keras.layers.core import TimeDistributedDense, Activation, Dropout | |
| from keras.layers.recurrent import GRU | |
| import numpy as np | |
| def _load_data(data, steps = 40): | |
| docX, docY = [], [] | |
| for i in range(0, data.shape[0]/steps-1): | |
| docX.append(data[i*steps:(i+1)*steps,:]) |
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
| NREP = 30000; | |
| N = 1000; | |
| K = 5; | |
| p_random = nan(NREP, 1); | |
| p_cluster = nan(NREP, 1); | |
| parfor rep=1:NREP | |
| data = randn(N, 1); | |
| random_group = mod(randperm(N), K); |
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
| /** | |
| * bisecting <master> <input> <nNodes> <subIterations> | |
| * | |
| * divisive hierarchical clustering using bisecting k-means | |
| * assumes input is a text file, each row is a data point | |
| * given as numbers separated by spaces | |
| * | |
| */ | |
| import org.apache.spark.SparkContext |
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
| #!/public/spark-0.9.1/bin/pyspark | |
| import os | |
| import sys | |
| # Set the path for spark installation | |
| # this is the path where you have built spark using sbt/sbt assembly | |
| os.environ['SPARK_HOME'] = "/public/spark-0.9.1" | |
| # os.environ['SPARK_HOME'] = "/home/jie/d2/spark-0.9.1" | |
| # Append to PYTHONPATH so that pyspark could be found |
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
| # -*- coding: utf-8 -*- | |
| import datetime | |
| from numpy import asarray, ceil | |
| import pandas | |
| import rpy2.robjects as robjects | |
| def stl(data, ns, np=None, nt=None, nl=None, isdeg=0, itdeg=1, ildeg=1, | |
| nsjump=None, ntjump=None, nljump=None, ni=2, no=0, fulloutput=False): |
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
| http://answers.oreilly.com/topic/460-how-to-benchmark-a-hadoop-cluster/ | |
| http://www.michael-noll.com/blog/2011/04/09/benchmarking-and-stress-testing-an-hadoop-cluster-with-terasort-testdfsio-nnbench-mrbench/ | |
| ## MR pi | |
| https://gist.github.com/jeongho/371aaed47ab462d79851 | |
| ## Terasort | |
| https://gist.github.com/jeongho/3b8c028f5e8409c3a10a | |
| ## TestDFSIO |
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
| from pyspark import SparkContext | |
| import numpy as np | |
| from sklearn.cross_validation import train_test_split, Bootstrap | |
| from sklearn.datasets import make_classification | |
| from sklearn.metrics import accuracy_score | |
| from sklearn.tree import DecisionTreeClassifier | |
| def run(sc): |
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
| stratified <- function(df, group, size, select = NULL, | |
| replace = FALSE, bothSets = FALSE) { | |
| if (is.null(select)) { | |
| df <- df | |
| } else { | |
| if (is.null(names(select))) stop("'select' must be a named list") | |
| if (!all(names(select) %in% names(df))) | |
| stop("Please verify your 'select' argument") | |
| temp <- sapply(names(select), | |
| function(x) df[[x]] %in% select[[x]]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder