Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
output$acronyms <- DT::renderDataTable({ | |
firstDate <- input$timelineGroups_window[1] | |
lastDate <- input$timelineGroups_window[2] | |
data <- input$timelineGroups_data %>% | |
select(label,start,end) %>% | |
filter((is.na(end) & (start > firstDate & start < lastDate)) | | |
(!is.na(end) & (start < lastDate & end > firstDate))) | |
acronyms %>% | |
filter(grepl( | |
paste(unlist(str_split(data$label,pattern=" ")),collapse="|"), |
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
# Returns the false-positive and true-positive rates at nPoints thresholds for | |
# the given true and predicted labels | |
# trueLabels: 0=FALSE; 1=TRUE | |
rocCurve <- function(trueLabels, predictedProbs, nPoints=100, posClass=1){ | |
# Allocates the threshold and ROC lists | |
thr <- seq(0,1,length=nPoints) | |
tpr <- numeric(nPoints) | |
fpr <- numeric(nPoints) | |
# Precalculates values for the positive and negative cases, used in the loop |
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(ROCR) | |
library(dplyr) | |
mnistResultsDF <- data.frame(actual = mnistTest$label, | |
fit = mnist.kknn$fit, | |
as.data.frame(mnist.kknn$prob)) | |
plotROCs <- function(df, digitList) { | |
firstPlot <- TRUE | |
legendList <- NULL |
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(caret) | |
library(kknn) | |
library(RColorBrewer) | |
library(cowplot) | |
mnist <- read.csv("data/mnist_small.csv", | |
colClasses = c(label = "factor")) | |
trainIndex <- createDataPartition(mnist$label, p = .8, | |
list = FALSE, |
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
mnist <- read.csv("data/mnist_small.csv", | |
colClasses = c(label = "factor")) | |
displayMnistSamples <- function(x) { | |
for(i in x){ | |
y = as.matrix(mnist[i, 2:785]) | |
dim(y) = c(28, 28) | |
image( y[,nrow(y):1], axes = FALSE, col = gray(0:255 / 255)) | |
text( 0.2, 0, mnist[i,1], cex = 3, col = 2, pos = c(3,4)) | |
} | |
} |
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(vcd) | |
mosaic( | |
~ Sex + Survived, | |
data = titanic, | |
main = "Mosaic plot for Titanic data: Gender vs. survival", | |
shade = TRUE, | |
split_vertical = TRUE, | |
labeling_args = list( | |
set_varnames = c( | |
Survived = "Survived?") |
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
#!/bin/bash | |
#Install any packages required by an R file that aren't already installed | |
if [ $# -ne 1 ]; then | |
echo $0: usage: installAllRPackages.bash file | |
exit 1 | |
fi | |
file=$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
require(datasets) | |
data("swiss") | |
require(GGally) | |
require(ggplot2) | |
my_fn <- function(data, mapping, ...){ | |
p <- ggplot(data = data, mapping = mapping) + | |
geom_point() + | |
geom_smooth(method=loess, fill="red", color="red", ...) + | |
geom_smooth(method=lm, fill="blue", color="blue", ...) |