0% found this document useful (0 votes)
8 views

Data Set

The document contains data on 100 observations with measurements on 5 variables. A neural network model is fitted to predict a binary outcome using the 4 predictor variables. The model performance is evaluated on a test data set, reporting type 1 error, type 2 error and correct predictions.

Uploaded by

Spandan Shashwat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Data Set

The document contains data on 100 observations with measurements on 5 variables. A neural network model is fitted to predict a binary outcome using the 4 predictor variables. The model performance is evaluated on a test data set, reporting type 1 error, type 2 error and correct predictions.

Uploaded by

Spandan Shashwat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Data Set

1 2 20.4 22 13 0

2 1 33 35 14 1

3 2 23 28 18 0

4 2 24 26 15.6 1

5 1 0 24 17 0

6 2 21 23 21 0

7 2 21 24 18.8 0

8 1 26 28 19 0

9 2 29 31 17 0

10 2 22 25 14 0

11 2 25 27 15 0

12 2 23 28.5 16 1

13 1 26 29 16.5 1

14 1 0 25 13 1

15 2 26 30 0 0

16 1 0 24 18.5 1

17 1 21 26.5 13.5 0

18 1 22 26 16 0

19 2 0 25 13 1

20 1 21 23 17 1

21 2 20 24 13 0

22 1 20 22.5 17 0

23 1 25 27.5 12 1

24 1 27 30 15 0

25 2 22 24 0 1

26 1 0 25 16.6 1
27 1 0 25 13 0

28 2 30 31 19 0

29 2 24 28 17.5 0

30 1 23 26 16.5 0

31 1 0 25.5 12 0

32 2 22 25 16.5 0

33 2 0 24 17 1

34 2 20 23.2 12.5 0

35 2 21.2 25 14 0

36 2 0 23.4 15 0

37 1 0 24.4 12.5 0

38 2 25.5 31 19 0

39 1 25 28 18 0

40 1 0 25.6 16 0

41 2 22 26 13 0

42 1 24 28 13 0

43 2 0 25 15 0

44 1 28 31 16 0

45 2 0 24 12.5 0

46 1 23 27 16 0

47 2 30 32.5 16.5 0

48 1 22 27 14.5 0

49 1 21 23 12 1

50 2 24 26 17
0

51 1 19 23 13.7 0 0

52 1 0 24.8 17 1 0
53 1 20 21 14 0 1

54 2 22 24 16 0 0

55 1 21 23 13.2 1 1

56 2 22 27 16 1 0

57 1 0 24.8 13.5 0 0

58 1 22 25 12.8 0 0

59 1 23 28 14.4 0 0

60 1 20 25 15 1 0

61 1 20 25 12.5 0 0

62 1 24 27 15.4 1 0

63 2 22 26 14.8 0 0

64 1 23 28 16.4 0 0

65 2 24 28 16 0 0

66 1 23 28.5 15.8 0 0

67 2 21 24 12 0 0

68 1 20 24.6 13.8 0 0

69 1 26 32 18 0 0

70 2 24 26.4 16.5 0 0

71 1 24.5 28 14 1 0

72 1 26 28 15 1 1

73 2 18 26 13 0 0

74 1 26 29.5 14.5 1 0

75 2 25 26.5 18 0 0

76 1 27 30 18 0 0

77 2 23 26 17.5 0 0

78 1 26 28 18 0 0

79 1 30 31.5 16.5 1 1
80 1 28 30.5 13.6 0 1

81 2 23 26.5 12.8 1 0

82 2 28 29.5 17.4 0 0

83 2 22.4 26 18 0 0

84 2 23 27 15.8 0 0

85 2 28 30 17.5 0 0

86 1 26 29 13 1 0

87 2 23 27 16 0 0

88 1 22 26 15.8 1 0

89 2 23 26.8 0 1 0

90 2 25 27 0 1 1

91 1 28 31.5 16.6 0 0

92 2 23.5 28 18.5 0 0

93 1 23 29 18 0 0

94 2 26 27.5 18 1 0

95 1 23 30 15.5 0 0

96 1 25 28.5 15.8 0 0

97 2 27 29.5 14.4 0 0

98 1 20.5 22 12.8 0 1

99 1 24 29 13 0 0

100 2 23 25 15 0 0
Neural Net:

Results
Type 1 error 11
Type 2 error 3
Correct prediction 4+32= 36
Efficiency= 72%
R coding:
# install package

install.packages("neuralnet")

# creating training data set

TKS=c(2,1,2,2,1,2,2,1,2,2,2,2,1,1,2,1,1,1,2,1,2,1,1,1,2,1,1,2,2,1,1,
2,2,2,2,2,1,2,1,1,2,1,2,1,2,1,2,1,1,2)

sks=c(20.4,33,23,24,0,21,21,26,29,22,25,23,26,0,26,0,21,22,0,21,20,2
0,25,27,22,0,0,30,24,23,0,22,0,20,21.2,0,0,25.5,25,0,22,24,0,28,0,23
,30,22,21,24)

mks=c(22,35,28,26,24,23,24,28,31,25,27,28.5,29,25,30,24,26.5,26,25,2
3,24,22.5,27.5,30,24,25,25,31,28,26,25.5,25,24,23.2,25,23.4,24.4,31,
28,25.6,26,28,25,31,24,27,32.5,27,23,26)

pks=c(13,14,18,15.6,17,21,18.8,19,17,14,15,16,16.5,13,0,18.5,13.5,16
,13,17,13,17,12,15,0,16.6,13,19,17.5,16.5,12,16.5,17,12.5,14,15,12.5
,19,18,16,13,13,15,16,12.5,16,16.5,14.5,12,17)

died=c(0,1,0,1,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0
,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0)

df=data.frame(TKS,sks,mks,pks,died)

# load library

require(neuralnet)

# fit neural network

nn=neuralnet(died~TKS+sks+mks+pks,data=df, hidden=3,act.fct =
"logistic",

linear.output = FALSE)

# plot neural network

plot(nn)

# creating test set

TKS=c(1,1,1,2,1,2,1,1,1,1,1,1,2,1,2,1,2,1,1,2,1,1,2,1,2,1,2,1,1,1,2,
2,2,2,2,1,2,1,2,2,1,2,1,2,1,1,2,1,1,2)

sks=c(19,0,20,22,21,22,0,22,23,20,20,24,22,23,24,23,21,20,26,24,24.5
,26,18,26,25,27,23,26,30,28,23,28,22.4,23,28,26,23,22,23,25,28,23.5,
23,26,23,25,27,20.5,24,23)
mks=c(23,24.8,21,24,23,27,24.8,25,28,25,25,27,26,28,28,28.5,24,24.6,
32,26.4,28,28,26,29.5,26.5,30,26,28,31.5,30.5,26.5,29.5,26,27,30,29,
27,26,26.8,27,31.5,28,29,27.5,30,28.5,29.5,22,29,25)

pks=c(13.7,17,14,16,13.2,16,13.5,12.8,14.4,15,12.5,15.4,14.8,16.4,16
,15.8,12,13.8,18,16.5,14,15,13,14.5,18,18,17.5,18,16.5,13.6,12.8,17.
4,18,15.8,17.5,13,16,15.8,0,0,16.6,18.5,18,18,15.5,15.8,14.4,12.8,13
,15)

test=data.frame(TKS,sks,mks,pks)

## Prediction using neural network

Predict=compute(nn,test)

Predict$net.result

# Converting probabilities into binary classes setting threshold


level 0.5

prob <- Predict$net.result

pred <- ifelse(prob>0.5, 1, 0)

pred

You might also like