View source_patient_data_india.R
rm(list = ls()) | |
# Load relevant libraries ----------------------------------------------------- | |
library(stringr) | |
library(data.table) | |
# ============================================================================= | |
# COVID 19-India API: A volunteer-driven, crowdsourced database | |
# for COVID-19 stats & patient tracing in India | |
# ============================================================================= |
View lm_linear_algebra.R
### Linear Regression Using lm() ---------------------------------------- | |
data("swiss") | |
dat <- swiss | |
linear_model <- lm(Fertility ~ ., data = dat) | |
summary(linear_model) | |
# Call: | |
# lm(formula = Fertility ~ ., data = dat) | |
# |
View remove_missing_levels.R
remove_missing_levels <- function(fit, test_data) { | |
library(magrittr) | |
# https://stackoverflow.com/a/39495480/4185785 | |
# drop empty factor levels in test data | |
test_data %>% | |
droplevels() %>% | |
as.data.frame() -> test_data | |
View factor_new_levels.R
library(data.table) | |
train <- fread('train.csv'); test <- fread('test.csv') | |
# consolidate the 2 data sets after creating a variable indicating train / test | |
train$flag <- 0; test$flag <- 1 | |
dat <- rbind(train,test) | |
# change outcome, var_b and var_e into factor var | |
dat$outcome <- factor(dat$outcome) |
View AirPassengers.Rmd
--- | |
title: "ARIMA Modeling in R" | |
output: html_document | |
--- | |
Let's start off by loading relevant R libraries! | |
```{r include = FALSE} | |
library(tseries) | |
library(zoo) | |
library(forecast) |
View rice_strucchange.R
library(xlsx) | |
library(forecast) | |
library(tseries) | |
library(strucchange) | |
## load the data from a CSV or Excel file. This example is done with an Excel sheet. | |
prod_df <- read.xlsx(file = 'agricultural_productivity.xls', sheetIndex = 'Sheet1', rowIndex = 8:65, colIndex = 2, header = FALSE) | |
colnames(prod_df) <- c('Rice') | |
## store rice data as time series objects | |
rice <- ts(prod_df$Rice, start=c(1951, 1), end=c(2008, 1), frequency=1) |
View strucchange_usage.R
# assuming you have a 'ts' object in R | |
# 1. install package 'strucchange' | |
# 2. Then write down this code: | |
library(strucchange) | |
# store the breakdates | |
bp_ts <- breakpoints(ts ~ 1) |
View experimentsWithData.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View graphUndirected_output.txt
{} | |
{} | |
["A:['B', 'C', 'E']", "C:['A', 'B', 'D', 'E']", "B:['A', 'C', 'D']", "E:['A', 'C']", "D:['B', 'C']"] | |
[[ 0. 1. 1. 0. 1.] | |
[ 1. 0. 1. 1. 0.] | |
[ 1. 1. 0. 1. 1.] |
View graphUndirected.py
class Vertex: | |
def __init__(self, vertex): | |
self.name = vertex | |
self.neighbors = [] | |
def add_neighbor(self, neighbor): | |
if isinstance(neighbor, Vertex): | |
if neighbor.name not in self.neighbors: | |
self.neighbors.append(neighbor.name) | |
neighbor.neighbors.append(self.name) |
NewerOlder