Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

STAT 318/462:  Data Mining

Assignment 1

2022

1.  (3 marks) Suppose we collect data for a group of students that have taken STAT318 with variables X1  = hours spent studying per week, X2  = number of classes attended

and

Y = 

We fit a logistic regression model and find the estimated coefficients to be βˆ0 = 16, βˆ1 = 1.6

(a) Write explicitly the equation for (1) the probability of receiving a GPA ≥ 7 and (2) the log-odds of receiving a GPA ≥ 7 as a function of the model variables. Explain what the model coefficient tell about the relationship between variables and GPA.

(b) Estimate the probability of a student getting a GPA value ≥ 7 in STAT318 if they study for 5 hours per week and attend all 34 classes.

(c) If a student attends 18 classes, how many hours do they need to study per week to have a 50% chance of getting a GPA value ≥ 7 in STAT318?

2.  (4 marks) Describe one pro and one con of flexible (versus a less flexible) approach for regression. Under what conditions might a less flexible approach be preferred?

3.  (6 marks) Consider a binary classification problem Y ∈ {0, 1} with one predictor X . The prior probability of being in class 0 is Pr(Y  = 0) = π0   = 0.6 and the density function for X in class 0 is a standard normal

f0 (x) = Normal(0, 1)

The density function for X in class 1 is also normal, but with µ = 1 and σ 2 = 0.5 f1 (x) = Normal(1, 0.5)

(a)  Plot π0 f0 (x) and π 1 f1 (x) in the same figure.

(b) Find the  Bayes decision boundary  (Hint:   you will need to solve the equation π0 f0 (x) = π1 f1 (x), which defines the boundary. Preferibly, do this by using some mathematics, rather than by numerical approximation).

(c) Using Bayes classifier, classify the observation X = 2.5. Justify your prediction.

(d) What is the probability that an observation with X = 1 is in class 1?

Recall:

The normal density function takes the form:

f(x) =  exp ( (x µ)2 ) .

For normal densities, probabilities can be calculated in R as follows: P(X ≤ x) = pnorm(x,µ,σ)

4.  (8 marks) In this question, you will fit kNN regression models to the Auto data set to predict Y = mpg using X = horsepower.  This data has been divided into training and testing sets: AutoTrain .csv and AutoTest .csv (download these sets from Learn). The kNN() R function on Learn should be used to answer this question (you  need to run the kNN code  before calling the function).

(a)  Perform kNN regression with k  =  2, 4, 8, 16, 32, 64 and  128,  (learning from the training data) and compute the training and testing MSE for each value of k . Do take care in using the right observed y-values (testing or training) for estimating testing and training MSE.

(b) Which value of k performed best? Explain.

(c)  Plot the training data, testing data and the best kNN model in the same figure. Include your name somewhere in the plot.  (The points() function  is  useful  to plot the kNN model because it is discontinuous .)

(d)  Describe the bias-variance trade-off for kNN regression and how it is influenced by the choice of k .

5.  (10  marks) In this question, you will fit a logistic regression model to predict the probability of a banknote being forged using the Banknote data set. This data has been divided into training and testing sets:  BankTrain .csv and BankTest .csv (download these sets from Learn).   The response variable is y  (the fifth column), where y  =  1 denotes a forged banknote and y = 0 denotes a genuine banknote. Although this data set has four predictors, you will be using x1  and x3  to fit your model1 .

(a)  Perform multiple logistic regression using the training data.  Comment on the model obtained.

(b)  Suppose we classify observations using

f(x) =

i.  Plot the training data (using a different symbol for each class) and the decision boundary for θ = 0.5 on the same figure.

ii. Using θ = 0.5, compute the confusion matrix for the testing set and comment on your output.

iii.  Compute confusion matrices for the testing set using θ = 0.6 and compare it with the one for θ = 0.5.  Comment on your output.  Describe a situation when the θ = 0.6 model may be the preferred model.