Skip to content

Instantly share code, notes, and snippets.

View anglilian's full-sized avatar

Ang Li-Lian anglilian

View GitHub Profile
@anglilian
anglilian / layoutparser.ipynb
Created March 22, 2022 22:35
layoutparser.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def white_band(img, side):
"""
Determine best position to crop image
Parameters:
img (array): Binarised and skew corrected image
type (str) : Side of image to crop (top, bottom, center, left or right)
Returns:
(int): Position on image to crop
@anglilian
anglilian / CS110_Activity_Scheduler.ipynb
Last active December 23, 2020 03:18
CS110 Location Based Assignment for an activity scheduler in the day of the life of a Minervan.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anglilian
anglilian / leave2out.r
Last active April 15, 2020 09:12
CS112 Final Project Extension Code
#leave-two-out test + matching
# Clear the workspace
rm(list = ls())
#load the required libraries
#Run the commented code to install the libraries
#install.packages("Synth")
#install.packages("gtools")
@anglilian
anglilian / Q1_Bonus.r
Last active March 30, 2020 13:07
CS112 Causal Inference Assignment
library(Matching)
library(plyr)
foo <- read.csv(url("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00089202-1711/daughters.csv"))
set.seed(2324)
X = cbind(foo$Dems,foo$Repubs , foo$Christian , foo$age, foo$srvlng , foo$demvote, #added 6 more variables
foo$Catholic, foo$Protestant, foo$OthParty,foo$OtherC, foo$OtherR, foo$none)
Y= foo$nowtot
genout <- GenMatch(Tr = foo$treat, X = X, pop.size = 20, nboots=250)
diamond <- read.csv("diamond.csv") #import data
member <- c()
nonmember <-c()
for (x in 1:3) { #iterate over each row
member[x] <- diamond$Member.Number.of.purchases[x]/(diamond$Member.Number.of.online.visitors[x]+diamond$Member.Number.of.purchases[x])*100 #percentage of members who bought
nonmember[x] <- diamond$Non.Member.Number.of.purchases[x]/(diamond$Non.Member.Number.of.online.visitors[x]+diamond$Non.Member.Number.of.purchases[x])*100 #percentage of nonmembers who made purchases
}
membership <- rbind(member, nonmember) #creating a table
colnames(membership) <- c("31-40","41-50", "51-60") #changing the table head
library(ggplot2)
library(arm)
###QUESTION 1###
##PART A##
#Loading data from the CSV file
sesame <- read.csv("https://tinyurl.com/w1g163b")
#Splitting the data into two datasets with control and treatment data
sesame_treat <- subset(sesame, sesame$treatment == 1)
sesame_cont <- subset(sesame, sesame$treatment == 0)
##SETTING UP DATA
foo <- read.csv("https://tinyurl.com/yb4phxx8")
names(foo)
dim(foo)
head(foo)
date.columns <- c(11,12,14,15,16,17,18,25)
for (i in date.columns) {