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 __future__ import division | |
#given the mean of a set of data and | |
#get a single additional number. Given the number of observations in the | |
#existing data, the old mean and the new value | |
def mean(oldmean, n, x): | |
return (oldmean * n + x) / (n + 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
#Compute the likelihood of observing a sequence of die rolls | |
#Likelihood is the probability of getting the specific set of rolls | |
#in the given order | |
#Given a multi-sided die whose labels and probabilities are | |
#given by a Python dictionary called dist and a sequence (list, tuple, string) | |
#of rolls called data, complete the function likelihood | |
def likelihood(dist,data): | |
return reduce(lambda acc, x: acc * dist[x], data, 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
from decimal import Decimal, getcontext | |
from vector import Vector | |
getcontext().prec = 30 | |
class Line(object): | |
__NO_NONZERO_ELTS_FOUND_MSG = 'No nonzero elements found' |
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
log_factorial <- function (n) { | |
# Return the log of factorial(n) for any integer n > 0 | |
if (n <= 1) | |
return (0) | |
return (log(n) + log_factorial(n - 1)) | |
} | |
sum_log_factorial <- function (n) { | |
# Return the sum of log_factorial(i) for i in 1..n | |
sum <- 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
--- | |
title: 'Project 2: Modeling and Evaluation' | |
subtitle: '<p>CSE6242 - Data and Visual Analytics</p><p>Due: Friday, April 21, 2017 | |
at 11:59 PM UTC-12:00 on T-Square</p>' | |
output: | |
pdf_document: default | |
html_document: default | |
--- | |
# 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
# AC4: Visualize Vehicular Accident Non-motorist Mortalities per State | |
# inspirational reference: https://blog.dominodatalab.com/geographic-visualization-with-rs-ggmaps/ | |
# infrastructure | |
install.packages("ggmap", type = "source") | |
library(ggmap) | |
setwd("~/Google Drive/gatech/dva/ac4") # **** Needs to accomodate particular workstation **** | |
vas <- read.csv("vehicle-accidents.csv") | |
# only continental states |
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
# Activity: Time Series Analysis | |
library(zoo) # basic time series package | |
library(xts) # eXtensible Time Series package | |
data_dir <- "data" | |
label_dir <- "labeled_windows" | |
load_ts <- function(csv_filename) { | |
# Load and return time series data from a CSV file. |
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
#!/usr/bin/Rscript | |
# 2. Log Gamma (Loop) | |
log_gamma_loop = function(n) { | |
acc = 0 | |
if (n > 1) { | |
for (i in 1:(n-1)) { | |
acc = acc + log(i) | |
} | |
} else if (n < 1) acc = -Inf # emulating log(<=0) return |
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
# tidyverse (includes ggplot2) | |
install.packages("tidyverse") | |
library(tidyverse) | |
# midwest data | |
data("midwest") | |
# 1. Professional Education by State | |
# aggregate all counties up to their states (Interpretation A @300) |
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
# hw3.R Logistic Regression | |
# 0. Data Preprocessing | |
# b | |
train <- read.csv("mnist_train.csv", header = F) | |
test <- read.csv("mnist_test.csv", header = F) | |
# c, d, e | |
class.indx <- 785 |