-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.R
54 lines (39 loc) · 1.4 KB
/
server.R
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
# Cleans workspace
?rm
# Setting up packages on our workspace
library('neuralnet',lib="/home/ravi/R/x86_64-pc-linux-gnu-library/3.0")
library('shiny')
# Setting directory to get the file
setwd('.')
directory <- getwd()
dat <- read.csv(paste(directory,'/parkinsons.data', sep=""), header = TRUE, sep = ",")
# Removing the 'name' column
features_total <- dat[,-1]
# Removing the status column
features_total <- features_total[,-17]
# Our training vector
status <- dat[,18]
features_train = features_total[1:150,]
status_train = status[1:150]
train <- data.frame(features_train, status_train)
n <- names(train)
f <- as.formula(paste('status_train ~', paste(n[!n %in% 'status_train'], collapse = ' + ')))
# ***********************************
# Making the model, some instructions
# ***********************************
# use hidden = c(x,y) to have x and y no. of neurons in 1st and 2nd hidden layers
# tweak with the parameters for better results, use help(neuralnet) for more.
net <- neuralnet(f, train, hidden = 10, threshold=0.01)
test_features <- features_total[150:nrow(features_total),]
status_test = status[150:length(status)]
net.results <- compute(net, test_features)
print(net.results$net.result)
result <- (net.results$net.result > 0.5)
print("Number of false reports:")
flaws <- sum(result!=status_test)
print(flaws)
shinyServer(function(input, output) {
output$view <- renderPrint({
print("Foo")
})
})