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
# Revision: 2013-01-09 12:34:09 -0600 | |
getYahooStockUrl <- function(symbol, start, end, type="m") { | |
# Creates a Yahoo URL for fetching historical stock data | |
# | |
# Args: | |
# symbol - the stock symbol for which to fetch data | |
# start - the date (CCYY-MM-DD) to start fetching data | |
# end - the date (CCYY-MM-DD) to finish fetching data | |
# type - daily/monthly data indicator ("d" or "m") |
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
drafts://x-callback-url/import_action?type=URL&name=Search%20Tweetbox&url=tweetbot%3A%2F%2F%2Fsearch%3Fquery%3D%5B%5Bdraft%5D%5D%2520lang%253Aen%2520-filter%253Aretweet%2520-%2522RT%2520%2522 |
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
vif_func<-function(in_frame,thresh=10,trace=T,wts=NULL,...){ | |
library(fmsb) | |
if(any(!'data.frame' %in% class(in_frame))) in_frame<-data.frame(in_frame) | |
if(is.null(wts)) | |
wts <- rep(1, ncol(in_frame)) | |
if(!is.null(wts)) | |
if(length(wts)!=ncol(in_frame)) stop('length of weights must equal number of variables') |
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
kripp.alpha<-function (x, method = c("nominal", "ordinal", "interval", "ratio")) { | |
if(missing(x)) | |
stop("kripp.alpha(x,method=c(\"nominal\",\"ordinal\",\"interval\",\"ratio\"))\n", | |
"\twhere x is a classifier by object matrix of classifications or scores\n") | |
method <- match.arg(method) | |
coincidence.matrix<-function(x) { | |
levx<-(levels(as.factor(x))) | |
nval<-length(levx) | |
cm<-matrix(rep(0, nval * nval), nrow = nval) | |
dimx<-dim(x) |
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 your local---# | |
ssh -i yhat.pem ubuntu@your-ec2-ip-address | |
#---on the server---# | |
# let's add a user | |
sudo adduser greg | |
# update | |
sudo apt-get update |
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 urllib2 | |
import urllib | |
from bs4 import BeautifulSoup | |
def processURL(url): | |
subEntryRequest = urllib2.Request(url, headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36'}) | |
try: | |
return urllib2.urlopen(subEntryRequest).read() | |
except: | |
return None |
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
cols <- names(train)[1:12] | |
system.time(clf <- randomForest(factor(quality) ~ ., data=train[,cols], ntree=20, nodesize=5, mtry=9)) | |
# user system elapsed | |
# 0.366 0.006 0.372 | |
table(test$quality, predict(clf, test[cols])) | |
# 3 4 5 6 7 8 9 | |
# 3 0 0 4 5 0 0 0 | |
# 4 0 0 35 22 1 0 0 | |
# 5 0 0 375 137 6 1 0 |
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
# Create a simple data frame for testing | |
df <- data.frame(POSIXtime = seq(as.POSIXct('2013-08-02 12:00'), | |
as.POSIXct('2013-08-06 05:00'), len = 45), | |
x = seq(45)) | |
# The Subset Examples | |
# | |
# All data on 2013-08-06 | |
sub.1 <- subset(df, format(POSIXtime,'%d')=='06') |
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
#include <iostream> | |
using namespace std; | |
struct PocketCard { | |
char x; | |
int y; | |
}; |
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
#include <iostream> | |
using namespace std; | |
void getResult(char str[]){ | |
int numbers[26]; | |
for(int j = 0; j < 26; j ++) | |
numbers[j] = 0; |