-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.Rapp.history
186 lines (186 loc) · 7.33 KB
/
.Rapp.history
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
save.pkg.list <- installed.packages()[is.na(installed.packages()[ , "Priority"]), 1]
save(save.pkg.list, file="pkglist.Rdata")
load("pkglist.Rdata")#
install.packages(save.pkg.list)
save.pkg.list
typeof(save.pkg.list)
x<-x[-which(x==4)]
save.pkg.list<-save.pkg.list[-which(save.pkg.list=="financial")]
load("pkglist.Rdata")#
install.packages(save.pkg.list)
save.pkg.list<-save.pkg.list[-which(save.pkg.list=="zoo")]
save.pkg.list
save.pkg.list<-save.pkg.list[-which(save.pkg.list=="financial")]
save.pkg.list
load("pkglist.Rdata")#
install.packages(save.pkg.list)
save.pkg.list<-save.pkg.list[-which(save.pkg.list=="financial")]
install.packages(save.pkg.list)
Sys.getenv("PATH")
load("pkglist.Rdata")
save.pkg.list<-save.pkg.list[-which(save.pkg.list=="financial")]
install.packages(save.pkg.list)
library(party)#
library(rpart)#
library(ggplot2)#
library(randomForest)
head(kyphosis)
summary(kyphosis)
length(kyphosis)
require(devtools)
install_github("slidify", "ramnathv")
affairs.df.trainplot = predict(preProcess(affairs.df.train[,-10], method="range"), affairs.df.train[,-10])#
# The featurePlot highlight 3 variable (alcohol content, volatile acidity and chlorides) that provide separation with regard to the 'good' classification#
featurePlot(affairs.df.trainplot, affairs.df.train$good, "box")
library(AER)#
library(corrplot)#
library(corrgram)#
library(caret)#
library(randomForest)#
library(klaR)#
library(pROC)#
#
# Replace the path here with the appropriate one for your machine#
myprojectpath = "/Users/eoinbrazil/Desktop/DublinR/TreesAndForests/DublinR-ML-treesandforests/"#
#
# Set the working directory to the current location for the project files#
setwd(myprojectpath)#
#
# Replace the path here with the appropriate one for your machine#
scriptpath = paste(myprojectpath, "scripts/", sep="")#
datapath = paste(myprojectpath, "data/", sep="")#
graphpath = paste(myprojectpath, "graphs/", sep="")#
# Set the seed so comparisons can be later made between the methods#
set.seed(2323)#
#
# Load Affairs data#
data(Affairs)#
#
# Explore the first ten records of the dataset to take a peek#
head(Affairs)#
#
# Look to get a summary of the dataset for each variable in the dataframe#
summary(Affairs)#
#
# Add some additional fields to data to for the correlation analysis#
Affairs$male <- mapvalues(Affairs$gender, from = c("female", "male"), to = c(0, 1))#
Affairs$male <- as.integer(Affairs$male)#
Affairs$male <- sapply(Affairs$male, function(x) x-1)#
Affairs$kids <- mapvalues(Affairs$children, from = c("no", "yes"), to = c(0, 1))#
Affairs$kids <- as.integer(Affairs$kids)#
Affairs$kids <- sapply(Affairs$kids, function(x) x-1)#
#
# Add a field to indicate if there was any affairs#
Affairs$hadaffair[Affairs$affairs< 1] <- 'No'#
Affairs$hadaffair[Affairs$affairs>=1] <- 'Yes'#
Affairs$hadaffair <- as.factor(Affairs$hadaffair)#
table(Affairs$hadaffair)#
#
# Check that the fields are only numerical in the data frame#
sapply(Affairs[, -c(2,5,12)], is.numeric)#
#
# Explore the data set to identify and then we'll remove any moderately correlated variables (could change the correlation value from 0.65 to .9)#
affairs.corr <- cor(Affairs[, -c(2,5,12)])#
corrplot(affairs.corr, method = "number", tl.cex = 0.6)#
affairs.variables.corr <- findCorrelation(affairs.corr, 0.65)#
affairs.variables.corr.names <- colnames(affairs.corr[,affairs.variables.corr])#
#
# The dataset requires defined training and test subsets so let's remove some of the variables that don't see to add to the value and create these#
# in processing unwanted we also include the variables quality and color (13,15) as we want to remove these as well#
trainIndices = createDataPartition(Affairs$hadaffair, p = 0.8, list = F)#
#
unwanted = colnames(Affairs) %in% c("yearsmarried", "affairs")#
affairs.df.train = Affairs[trainIndices, !unwanted] #remove affairs and yearsmarried#
affairs.df.test = Affairs[!1:nrow(Affairs) %in% trainIndices, !unwanted]#
table(affairs.df.test$hadaffair)#
#
# The preProcess function helps determine values for predicator transforms on the training set and can be applied to this and future sets.#
# This is important as nnets and svms can require scaled and/or centered data which this function supports#
affairs.df.trainplot = predict(preProcess(affairs.df.train[,-10], method="range"), affairs.df.train[,-10])#
# The featurePlot highlight 3 variable (alcohol content, volatile acidity and chlorides) that provide separation with regard to the 'good' classification#
featurePlot(affairs.df.trainplot, affairs.df.train$good, "box")
sapply(affairs.df.train, is.numeric)
affairs.df.trainplot = predict(preProcess(affairs.df.train[,-c(3,10)], method="range"), affairs.df.train[,-c(3,10)])
head(affairs.df.train[, -c(3, 10)])
affairs.df.trainplot = predict(preProcess(affairs.df.train[,-c(1,3,10)], method="range"), affairs.df.train[,-c(1,3,10)])#
# The featurePlot highlight 3 variable (alcohol content, volatile acidity and chlorides) that provide separation with regard to the 'good' classification#
featurePlot(affairs.df.trainplot, affairs.df.train$good, "box")
affairs.df.trainplot
affairs.df.trainplot = predict(preProcess(affairs.df.train[,-c(1,3,10)], method="range"), affairs.df.train[,-c(1,3,10)])#
# The featurePlot highlight 3 variable (alcohol content, volatile acidity and chlorides) that provide separation with regard to the 'good' classification#
featurePlot(affairs.df.trainplot, affairs.df.train$good, "box")
sapply(affairs.df.train, is.numeric)
affairs.df.trainplot = predict(preProcess(affairs.df.train[,-c(1,3,10)], method="range"), affairs.df.train[,-c(1,3,10)])#
# The featurePlot highlight 3 variable (alcohol content, volatile acidity and chlorides) that provide separation with regard to the 'good' classification#
featurePlot(affairs.df.trainplot, affairs.df.train$hadaffair, "box")
install#
library(devtools)#
install_github("Nof", "openmhealth")#
#
#use#
nof1=wrap.norm(#
Pain=c(22, 18, 21,16, 22, 15, 23, 14), #
Fatigue=c(7,4,9,3,7,4,8,3), #
Drowsy=c(5,5,5,4,5,5,4,5), #
Sleep=c(4,2,4,1,4,1,4,1), #
Thinking=c(5,2,6,1,8,4,7,6), #
Constipation=c(10,7,10,6,9,5,10,3),#
Treat=c(0,1,0,1,0,1,0,1), #
conv.limit=1.05, #
niters=10000, #
setsize=1000, #
alphaprior = list("norm",0,1e-6),#
betaprior = list("norm",0,1e-6),#
varprior=list("sd","unif"),#
varprior.params=c(0,5)#
)
install.packages("opencpu")
library(opencpu)
install#
library(devtools)#
install_github("Nof", "openmhealth")#
#
#use#
nof1=wrap.norm(#
Pain=c(22, 18, 21,16, 22, 15, 23, 14), #
Fatigue=c(7,4,9,3,7,4,8,3), #
Drowsy=c(5,5,5,4,5,5,4,5), #
Sleep=c(4,2,4,1,4,1,4,1), #
Thinking=c(5,2,6,1,8,4,7,6), #
Constipation=c(10,7,10,6,9,5,10,3),#
Treat=c(0,1,0,1,0,1,0,1), #
conv.limit=1.05, #
niters=10000, #
setsize=1000, #
alphaprior = list("norm",0,1e-6),#
betaprior = list("norm",0,1e-6),#
varprior=list("sd","unif"),#
varprior.params=c(0,5)#
)
library(Nof)
library(openmhealth)
library(Nof)
install#
library(devtools)#
install_github("Nof", "openmhealth")#
#
#use#
nof1=wrap.norm(#
Pain=c(22, 18, 21,16, 22, 15, 23, 14), #
Fatigue=c(7,4,9,3,7,4,8,3), #
Drowsy=c(5,5,5,4,5,5,4,5), #
Sleep=c(4,2,4,1,4,1,4,1), #
Thinking=c(5,2,6,1,8,4,7,6), #
Constipation=c(10,7,10,6,9,5,10,3),#
Treat=c(0,1,0,1,0,1,0,1), #
conv.limit=1.05, #
niters=10000, #
setsize=1000, #
alphaprior = list("norm",0,1e-6),#
betaprior = list("norm",0,1e-6),#
varprior=list("sd","unif"),#
varprior.params=c(0,5)#
)
nof1
plot(nof1)
plot(nof1[[2]])