Skip to content

Instantly share code, notes, and snippets.

Zach Mayer zachmayer

Block or report user

Report or block zachmayer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zachmayer
zachmayer / AttentionWithContext.py
Created Sep 13, 2017 — forked from cbaziotis/AttentionWithContext.py
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
View AttentionWithContext.py
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
x (): input
kernel (): weights
Returns:
"""
if K.backend() == 'tensorflow':
View magic_future_computation.R
#Define the problem
t1 <- Sys.time()
set.seed(1)
n_nodes <- 300000L
n_edges <- 900000L
nodes <- 1L:n_nodes
edge_node_1 <- sample(nodes, n_edges, replace=TRUE)
edge_node_2 <- sample(nodes, n_edges, replace=TRUE)
#Sparse matrix
View openblas.sh
#Option 1 - install openblas with homebrew and link to CRAN installed R
brew tap homebrew/science
brew install openblas
ln -sf /usr/local/Cellar/openblas/0.2.12/lib/libopenblas.dylib /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib
#Option 2 - install r with openblas through homebrew
brew tap homebrew/science
brew install r --with-openblas
View helloworld.f
program hello
print *, "Hello World!"
end program hello
View 2.15.sh
cd /Library/Frameworks/R.framework/Resources/lib
# for vecLib use
ln -sf libRblas.vecLib.dylib libRblas.dylib
# for R reference BLAS use
ln -sf libRblas.0.dylib libRblas.dylib
@zachmayer
zachmayer / multiRF.R
Created May 10, 2013
A better multiRFfunction
View multiRF.R
multiRF <- function(X, Y, mtry_vector,...) {
stopifnot(require(doRNG))
stopifnot(require(randomForest))
stopifnot(is.numeric(mtry_vector))
stopifnot(all(mtry_vector>1))
foreach(i=mtry_vector,.combine=randomForest::combine,.packages='randomForest',.export=c('X','Y'),.inorder=FALSE) %dorng% {
View Demo2.R
#Setup
rm(list = ls(all = TRUE))
gc(reset=TRUE)
set.seed(1234) #From random.org
#Libraries
library(caret)
library(devtools)
install_github('caretEnsemble', 'zachmayer') #Install zach's caretEnsemble package
library(caretEnsemble)
View demo.R
#Setup
rm(list = ls(all = TRUE))
gc(reset=TRUE)
set.seed(42) #From random.org
#Libraries
library(caret)
library(devtools)
install_github('caretEnsemble', 'zachmayer') #Install zach's caretEnsemble package
View test.html
<html>
<head>
<title>Test</title>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="icon.png"/>
<style type="text/css">
body{ margin: 0px;}
</style>
View 1. Load Data.R
#Load the dataset, adjust, and convert to monthly returns
set.seed(42)
library(quantmod)
getSymbols('^GSPC', from='1990-01-01')
GSPC <- adjustOHLC(GSPC, symbol.name='^GSPC')
GSPC <- to.monthly(GSPC, indexAt='lastof')
Target <- ClCl(GSPC)
You can’t perform that action at this time.