Publications by H. K. Tseng
Statistical Learning: Week-10
Classifying Legendary Pokemons using SVM! Using SVM techniques to classify if a Pokemon is a legendary one. # install required packages in one-swoop install.packages(c("dplyr", "ggplot2", "tidyr", "reshape2", "caret", "skimr", "psych", "e1071", "data.table", "Matrix", "keras")) ## Installing packages into 'C:/Users/hktse/Documents/R/win-library/3....
487 sym R (36942 sym/145 pcs) 3 img
Understanding Support Hyperplane
Understanding separating hyperplane (or support hyperplane) # generate random data # random random seed for reproducibility set.seed(123) #set n = 500 data points. n <- 500 #Generate data frame with two uniformly distributed predictors lying between 0 and 1. df <- data.frame(x1 = runif(n), x2 = runif(n)) # create a va...
106 sym R (4806 sym/16 pcs) 4 img
Statistical Learning: Week-9
Ridge and LASSO regressions Fit ridge and LASSO regressions, interpret coefficients and visualize their variation across the range of \(\lambda\). # load the required packages and data library(glmnet) library(caret) library(plotmo) data(mtcars) names(mtcars) # as usual, check out what's inside the loaded dataframe ## [1] "mpg" "cyl" "disp"...
418 sym R (24994 sym/63 pcs) 4 img
Note: LASSO, Ridge, and Penalty explained
LASSO vs. Ridge LASSO and Ridge regression are regression methods that perform \(variable\) \(selection\) and \(regularization\) to enhance the prediction accuracy and interpretability of the statistical model. In short, they do two things Variable selection: identify important variables in the data that explain major variation in the outcome ...
4688 sym Python (10112 sym/41 pcs) 3 img
Statistical Learning: Week-8
set.seed(123) n = 10 xr = seq(0, n, by=.1) # generate a random data from a sin function plus some random errors yr = sin(xr/2) + rnorm(length(xr))/2 # combine x and y into a df for easy manipulation df = data.frame(x = xr, y = yr) # plot the data plot(df) lm.fit = lm(y ~ x, data = df) abline(lm.fit, col = "red") # If the degree of the p...
646 sym R (25161 sym/92 pcs) 20 img
Statistical Learning: Week-6
Binary outcome as a generalization of linear regression model with limited dependent variables Estimating a model of binary outcome using lm() function library(ISLR) data(Default) names(Default) ## [1] "default" "student" "balance" "income" ## convert the outcome variable "default" to numeric: Yes = 1, No = 0 # the ifelse logic: ifelse(if a var...
857 sym R (38844 sym/161 pcs) 7 img
Statistical Learning: Week-5
Non-normality test ## load Prestige data from the "car" package library(car) ## Loading required package: carData lm.fit <- lm(prestige ~ education, data = Prestige) plot(lm.fit) ## Shapiro test of normality shapiro.test(Prestige$prestige) ## ## Shapiro-Wilk normality test ## ## data: Prestige$prestige ## W = 0.97198, p-value = 0.02875 ...
1097 sym R (32547 sym/104 pcs) 15 img
Statistical Learning: Week 4
Fitting a linear model A description of variable names and measures can be seen here install.packages("ISLR") ## Installing package into 'C:/Users/hktse/Documents/R/win-library/3.6' ## (as 'lib' is unspecified) ## ## There is a binary version available but the source version is later: ## binary source needs_compilation ## ISLR 1.2 ...
343 sym R (14002 sym/64 pcs) 5 img
Statistical Learning: Week 3
Installing R and RStudio R is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing. RStudio is an integrated development environment for R, a programming language for statistical computing and graphics. You need to download base R in order to run RS...
2543 sym R (20701 sym/175 pcs) 12 img
Statistical Learning - Week 16
U.S. Armament Cooperation Network at a glance: 1992-2017 Structural Topic Models (STM) A gentle introduction using international armament cooperation (IAC) data # load required packages and data library(stm) ## stm v1.3.6 successfully loaded. See ?stm for help. ## Papers, resources, and other materials at structuraltopicmodel.com data_sub <- r...
219 sym R (132236 sym/37 pcs) 9 img