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
program hello | |
print *, "Hello World!" | |
end program hello |
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
#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 |
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
install.packages(c("caret","reshape2","plyr","caTools"),dependencies=c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")) |
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
#################################### | |
# Training parameters | |
#################################### | |
MyTrainControl=trainControl( | |
method = "repeatedCV", | |
number=10, | |
repeats=5, | |
returnResamp = "all", | |
classProbs = TRUE, | |
summaryFunction=twoClassSummary |
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
#Setup | |
rm(list = ls(all = TRUE)) #CLEAR WORKSPACE | |
#Directory | |
setwd("~/Overfitting") | |
#Load Required Packages | |
library('caTools') | |
library('caret') | |
library('glmnet') |
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(quantmod) | |
getSymbols(c('AHETPI','CES0500000003','CPIAUCSL','GASREGM'),src = "FRED") | |
getSymbols('XAU/USD',src = "oanda") | |
#Definitions: | |
#AHETPI = Average Hourly Earnings of Production and Nonsupervisory Employees: Total Private | |
#CES0500000003 = Average Hourly Earnings of All Employees: Total Private | |
#CPIAUCSL = Consumer Price Index for All Urban Consumers: All Items | |
#GASREGM = US Regular All Formulations Gas Price | |
#XAUUSD USD per 1 oz of gold. Last 500 days only |
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
multiRF <- function(x,...) { | |
foreach(i=x,.combine=combine,.packages='randomForest', | |
.export=c('X','Y'),.inorder=FALSE) %dopar% { | |
randomForest(X,Y,mtry=i,...) | |
} | |
} | |
multiRF(c(rep(3,10),rep(4,10),rep(5,10)),ntree=500) |
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
## Load googlepredictionapi and dependent libraries | |
library(rjson) | |
library(RCurl) | |
library(googlepredictionapi) | |
#Save dataframe to a file, upload to google storage, and train a model | |
write.csv(iris,'iris.csv') | |
model <- PredictionApiTrain(data='iris.csv', remote.file="gs://rdata/iris") | |
#Summarize model and predict for new 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
#Actual Recessions | |
getSymbols('USREC',src='FRED') | |
USREC <- USREC["1997-07-01::",] #Start from same period | |
#Compare recession now to warning last month | |
library(caret) | |
OneMonth <- Lag(P.Rec) | |
compare <- na.omit(merge(OneMonth,USREC)) | |
confusionMatrix(compare[,1],compare[,2],positive = '1') |
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
cor(iris[-5]) | |
pairs(iris[-5], bg=iris$Species, pch=21) |
OlderNewer