Publications by Michael Czarnecki
Assignment 3
Question 13 library(ISLR2) library(corrplot) ## corrplot 0.92 loaded summary(Weekly) ## Year Lag1 Lag2 Lag3 ## Min. :1990 Min. :-18.1950 Min. :-18.1950 Min. :-18.1950 ## 1st Qu.:1995 1st Qu.: -1.1540 1st Qu.: -1.1540 1st Qu.: -1.1580 ## Median :2000 Median : 0...
2220 sym R (14048 sym/93 pcs) 3 img
Assignment 4
Question 3 The K-fold cross-validation intails randomly dividing the set of observations into k groups of equal size. The first fold is the validation set and the method is fit on the remaining k-1 folds. The mean squared error is computed on the other observations. The process is completed k amount of times with a different group of observa...
1615 sym R (8317 sym/41 pcs)
Assignment 5
Question 2 Less flexible and hence will give improved prediction accuracy when its increase in bias is less than its decrease in variance. Lesso restricts the size of the regression coefficient which leads to decrease in variance but increase in bias. In ridge regression variance decreases and bias increases as coefficient tends to 0 which m...
5056 sym R (11857 sym/58 pcs) 6 img
Assignment 6
Question 6 library(ISLR2) library(boot) set.seed(15) cv.error <- rep(0,5) for (i in 1:5){ glm.fit <- glm(wage ~ poly(age,i),data=Wage) cv.error[i]<- cv.glm(Wage,glm.fit,K=10)$delta[1] } cv.error ## [1] 1676.192 1599.786 1596.256 1593.755 1595.106 plot(cv.error, type="b", xlab="Degree", ylab="Test MSE") points(which.min(cv.error), cv.e...
600 sym R (7625 sym/24 pcs) 5 img
Assignment 7
Chapter 8 Question 3) p <- seq(0, 1, 0.01) gini.index <- 2 * p * (1 - p) class.error <- 1 - pmax(p, 1 - p) cross.entropy <- - (p * log(p) + (1 - p) * log(1 - p)) par(bg = "papayawhip") matplot(p, cbind(gini.index, class.error, cross.entropy), pch=c(15,17,19) ,ylab = "gini.index, class.error, cross.entropy",col = c("darkolivegreen4" , "wheat"...
604 sym R (8960 sym/46 pcs) 7 img
Assignment 2
Question 2) The difference between the KNN classifier and KNN regression methods is that the classifier is used in situations where the response variable is categorical (qualitative), while the regressor is used in numerical situations (quantitative). The KNN classifier shows Y as 0 or 1, while the KNN regression method predicts the quantitat...
3155 sym R (12908 sym/41 pcs) 11 img
Assignment 8
Question 5 set.seed(421) x1 = runif(500) - 0.5 x2 = runif(500) - 0.5 y = 1 * (x1^2 - x2^2 > 0) plot(x1[y == 0], x2[y == 0], col = "red", xlab = "X1", ylab = "X2", pch = "+") points(x1[y == 1], x2[y == 1], col = "blue", pch = 4) lm.fit = glm(y ~ x1 + x2, family = binomial) summary(lm.fit) ## ## Call: ## glm(formula = y ~ x1 + x2, family...
471 sym R (10109 sym/46 pcs) 26 img