Below are the solutions to these exercises on model evaluation

############### # # # Exercise 1 # # # ############### 3/5

## [1] 0.6

3/7

## [1] 0.4285714

############### # # # Exercise 2 # # # ############### 100

## [1] 100

```
24
```

## [1] 24

```
94
```

## [1] 94

```
23
```

## [1] 23

############### # # # Exercise 3 # # # ############### (100+94)/241

## [1] 0.8049793

############### # # # Exercise 4 # # # ############### (23+24)/241

## [1] 0.1950207

############### # # # Exercise 5 # # # ############### 100/(100+23)

## [1] 0.8130081

100/(100+24)

## [1] 0.8064516

############### # # # Exercise 6 # # # ############### 24/(100+24)

## [1] 0.1935484

23/(23+94)

## [1] 0.1965812

############### # # # Exercise 7 # # # ############### 100/(100+23)

## [1] 0.8130081

100/(100+24)

## [1] 0.8064516

############### # # # Exercise 8 # # # ############### library(caTools) library(MASS) attach(housing) housing$Cont=ifelse(housing$Cont=="High",1,0) spl=sample.split(housing$Cont,SplitRatio = 0.7) Train=housing[spl==TRUE,] Test=housing[spl==FALSE,] model <- glm(Cont~.,family=binomial,data=Train) pred=predict(model,newdata = Test) table(Test$Cont,pred>0.5)

## ## FALSE TRUE ## 0 10 1 ## 1 8 3

############### # # # Exercise 9 # # # ############### 4/(4+5)

## [1] 0.4444444

4/(4+7)

## [1] 0.3636364

############### # # # Exercise 10 # # # ############### (4+6)/22

## [1] 0.4545455

(5+7)/22

## [1] 0.5454545

Jup says

I believe the equation you mention in Exercise 4 is incorrect. I believe it should read (FP+FN)/N.

Hasan Imtiaz says

Thanks. It has been corrected now