Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

intellify.R 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  1. ###########################################################################
  2. ############### Bias And Variance Tradeoff ###########
  3. setwd("E:/R (Data Science)/excel files")
  4. data <- read.csv("binary.csv")
  5. str(data)
  6. data$admit <- as.factor(data$admit)
  7. data$rank <- as.factor(data$rank)
  8. ############ training and testing data #############
  9. set.seed(123)
  10. id <- sample(2,nrow(data),replace = T,prob = c(.8,.2))
  11. train <- data[id == 1, ]
  12. test <- data[id ==2,]
  13. ##### Model ######
  14. model <-glm(admit ~ gpa+rank,train,family = "binomial")
  15. summary(model)
  16. # prediction training dataset
  17. p1<-predict(model,train,type="response")
  18. head(p1)
  19. head(train)
  20. # misclassification train
  21. pred1 <- ifelse(p1>.5,1,0)
  22. tab1 <- table(prediction=pred1,actual=train$admit)
  23. tab1
  24. sum(diag(tab1))/sum(tab1)
  25. # misclassification on test dataset
  26. p2 <-predict(model,test,type="response")
  27. head(p2)
  28. head(test)
  29. pred2 <- ifelse(p2>.5,1,0)
  30. tab2 <- table(predication =pred2,actual = test$admit)
  31. tab2
  32. sum(diag(tab2))/sum(tab2)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...