Skip to content

Commit b6affdc

Browse files
committed
2 parents aede72d + 8dbd5fc commit b6affdc

File tree

22 files changed

+546
-246
lines changed

22 files changed

+546
-246
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ before_install:
1717
script:
1818
- make all
1919
- make python
20-
- mvn test -f java/pom.xml
20+
- mvn clean test -f java/pom.xml
2121
- make test
2222
- make test_gcov --always-make
2323
- cd python

R/r.vw/R/dt2vw.R

+7-13
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,30 @@
1818
#'variables like '_', or same variables perceived differently like "_var" and "var"
1919
#'@import data.table
2020
#'@export
21-
dt2vw <- function(data, fileName, namespaces = NULL, target, weight = NULL, tag = NULL, hard_parse = F, append = F)
21+
dt2vw <- function(data, fileName, namespaces = NULL, target, weight = NULL, tag = NULL, hard_parse = FALSE, append = FALSE)
2222
{
2323

2424
data = setDT(data)
2525

2626
#change target if its boolean to take values in {-1,1}
27-
if(is.logical(data[[target]]) | sum(levels(factor(data[[target]])) == levels(factor(c(0,1)))) == 2)
27+
if(is.logical(data[[target]]) || sum(levels(factor(data[[target]])) == levels(factor(c(0,1)))) == 2)
2828
{
2929
data[[target]][data[[target]] == TRUE] = 1
3030
data[[target]][data[[target]] == FALSE] = -1
3131
}
32-
32+
3333
#if namespaces = NULL, define a unique namespace
3434
if(is.null(namespaces))
3535
{
3636
all_vars = colnames(data)[!colnames(data) %in% c(target, weight, tag)]
37-
namespaces <- list(A = list(varName = all_vars, keepSpace=F))
37+
namespaces <- list(A = list(varName = all_vars, keepSpace=FALSE))
3838
}
3939

4040
#parse variable names
4141
specChar = '\\(|\\)|\\||\\:'
4242
specCharSpace = '\\(|\\)|\\||\\:| '
4343

44-
parsingNames <- function(x)
45-
{
46-
ret = c()
47-
for(el in x)
48-
ret = append(ret, gsub(specCharSpace,'_', el))
49-
ret
50-
}
44+
parsingNames <- function(x) Reduce(c, lapply(x, function(X) gsub(specCharSpace,'_', X)))
5145

5246
#parse categorical variables
5347
parsingVar <- function(x, keepSpace, hard_parse)
@@ -89,7 +83,7 @@ dt2vw <- function(data, fileName, namespaces = NULL, target, weight = NULL, tag
8983

9084
for(namespaceName in names(namespaces))
9185
{
92-
Index[[namespaceName]] = sapply(data[,namespaces[[namespaceName]][['varName']],with=F], is.numeric)
86+
Index[[namespaceName]] = vapply(data[,namespaces[[namespaceName]][['varName']],with=FALSE], is.numeric, logical(1))
9387
#Header[[namespaceName]][Index[[namespaceName]]] = namespaces[[namespaceName]][['varName']][Index[[namespaceName]]]
9488
Header[[namespaceName]] = namespaces[[namespaceName]][['varName']]
9589

@@ -105,7 +99,7 @@ dt2vw <- function(data, fileName, namespaces = NULL, target, weight = NULL, tag
10599
}
106100

107101
#appending the name of the variable to its value for each categorical variable
108-
sapply(Index, FUN = function(x){sapply(names(x), FUN = function(y){if(x[[y]] == F){
102+
sapply(Index, FUN = function(x){sapply(names(x), FUN = function(y){if(!x[[y]]){
109103
set(data, i=NULL, y, paste0(y,"_",data[[y]]))
110104
}})})
111105

R/r.vw/R/vw.R

+18-18
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ vw <- function(training_data, validation_data, model='mdl.vw',
6969
## this should not create an unnecessary copy of the arguments
7070
data_args = list(train = training_data, val = validation_data)
7171
path_data_args = list(path_vw_data_train, path_vw_data_val)
72-
for(i in 1:2)
72+
for(i in seq_along(data_args))
7373
{
74-
if("data.frame" %in% class(data_args[[i]]))
74+
if (inherits(data_args[[i], "data.frame"))
7575
{
7676
if(is.null(target))
7777
stop(paste0(names(data_args)[i],
7878
"data argument: input argument is a data.frame, argument 'target' should be specified "))
7979

80-
if(class(path_data_args[[i]]) != "character")
81-
path_data_args[[i]] = paste0(tempdir(),"/", names(data_args)[i],".vw")
80+
if(! is.character(path_data_args[[i]]))
81+
path_data_args[[i]] = file.path(tempdir(),paste0(names(data_args)[i],".vw"))
8282

8383
dt2vw(data = data_args[[i]], fileName = path_data_args[[i]],
8484
namespaces = namespaces, target = target, weight = weight, tag = tag)
@@ -117,29 +117,29 @@ vw <- function(training_data, validation_data, model='mdl.vw',
117117

118118
if(is.null(out_probs))
119119
{
120-
out_probs = paste0(tempdir(),"/preds.vw")
121-
del_prob = T
120+
out_probs = file.path(tempdir(),"preds.vw")
121+
del_prob = TRUE
122122
}
123123
else
124-
del_prob = F
124+
del_prob = FALSE
125125

126126
validation_data = path_data_args[[2]]
127127
predict = sprintf('vw -t -i %s -p %s %s -d %s', model, out_probs, link_function, validation_data)
128128
system(predict)
129129

130130
if(do_evaluation){
131-
if("data.frame" %in% class(data_args[[2]]))
131+
if(inherits(data_args[[2]], "data.frame"))
132132
{
133133
if(is.null(validation_labels))
134134
{
135-
del_val = T
136-
validation_labels = paste0(tempdir(),"/val_labs.vw")
135+
del_val = TRUE
136+
validation_labels = file.path(tempdir(),"val_labs.vw")
137137
}
138138
else
139-
del_val = F
139+
del_val = FALSE
140140

141-
write.table(x = data_args[[2]][[target]], file = validation_labels, row.names = F,
142-
col.names = F)
141+
write.table(x = data_args[[2]][[target]], file = validation_labels, row.names = FALSE,
142+
col.names = FALSE)
143143
}
144144

145145
if(use_perf){
@@ -151,7 +151,7 @@ vw <- function(training_data, validation_data, model='mdl.vw',
151151
}
152152
}
153153

154-
if(verbose & do_evaluation){
154+
if(verbose && do_evaluation){
155155
cat('Model Parameters\n')
156156
cat(cmd)
157157
verbose_log = sprintf('AUC: %s', auc)
@@ -162,8 +162,8 @@ vw <- function(training_data, validation_data, model='mdl.vw',
162162
probs = fread(out_probs)[['V1']]
163163

164164
## delete temporary files
165-
for(i in 1:2)
166-
if("data.frame" %in% class(data_args[[i]]))
165+
for(i in seq_along(data_args))
166+
if(inherits(data_args[[i]], "data.frame"))
167167
file.remove(path_data_args[[i]])
168168
if(del_prob)
169169
file.remove(out_probs)
@@ -184,8 +184,8 @@ roc_auc <- function(out_probs, validation_labels, plot_roc, cmd, ...){
184184
stop('The length of the probabilities and labels is different')
185185

186186
# Fix cmd for adding it in title
187-
cmd = sapply(strsplit(cmd, '-f'), function(x) paste0(x, collapse='\n'))
188-
cmd = sapply(strsplit(cmd, '-c'), function(x) paste0(x, collapse='\n'))
187+
cmd = vapply(strsplit(cmd, '-f'), function(x) paste0(x, collapse='\n'), character(1))
188+
cmd = vapply(strsplit(cmd, '-c'), function(x) paste0(x, collapse='\n'), character(1))
189189

190190
# Plot ROC curve and return AUC
191191
roc = roc(labels, probs, auc=TRUE, print.auc=TRUE, print.thres=TRUE)

cs/azure/Properties/AssemblyInfo.cs

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
//------------------------------------------------------------------------------
2-
// <auto-generated>
3-
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.42000
5-
//
6-
// Changes to this file may cause incorrect behavior and will be lost if
7-
// the code is regenerated.
8-
// </auto-generated>
9-
//------------------------------------------------------------------------------
10-
11-
[assembly: System.Reflection.AssemblyTitle("Vowpal Wabbit")]
12-
[assembly: System.Reflection.AssemblyDescription("Vowpal Wabbit")]
13-
[assembly: System.Reflection.AssemblyCompany("Microsoft Corp")]
14-
[assembly: System.Reflection.AssemblyProduct("Vowpal Wabbit")]
15-
[assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2012-2016, Yahoo! Inc. 2007-2012, and many individua" +
16-
"l contributors. All rights reserved")]
17-
[assembly: System.Runtime.InteropServices.ComVisible(false)]
18-
[assembly: System.CLSCompliant(false)]
19-
[assembly: System.Runtime.InteropServices.Guid("6a577997-af00-4ca0-8453-fdc8bbdf2a57")]
20-
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21-
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
22-
23-
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
// Runtime Version:4.0.30319.42000
5+
//
6+
// Changes to this file may cause incorrect behavior and will be lost if
7+
// the code is regenerated.
8+
// </auto-generated>
9+
//------------------------------------------------------------------------------
10+
11+
[assembly: System.Reflection.AssemblyTitle("Vowpal Wabbit")]
12+
[assembly: System.Reflection.AssemblyDescription("Vowpal Wabbit")]
13+
[assembly: System.Reflection.AssemblyCompany("Microsoft Corp")]
14+
[assembly: System.Reflection.AssemblyProduct("Vowpal Wabbit")]
15+
[assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2012-2016, Yahoo! Inc. 2007-2012, and many individua" +
16+
"l contributors. All rights reserved")]
17+
[assembly: System.Runtime.InteropServices.ComVisible(false)]
18+
[assembly: System.CLSCompliant(false)]
19+
[assembly: System.Runtime.InteropServices.Guid("6a577997-af00-4ca0-8453-fdc8bbdf2a57")]
20+
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21+
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
22+
23+
+23-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
//------------------------------------------------------------------------------
2-
// <auto-generated>
3-
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.42000
5-
//
6-
// Changes to this file may cause incorrect behavior and will be lost if
7-
// the code is regenerated.
8-
// </auto-generated>
9-
//------------------------------------------------------------------------------
10-
11-
[assembly: System.Reflection.AssemblyTitle("Vowpal Wabbit")]
12-
[assembly: System.Reflection.AssemblyDescription("Vowpal Wabbit")]
13-
[assembly: System.Reflection.AssemblyCompany("Microsoft Corp")]
14-
[assembly: System.Reflection.AssemblyProduct("Vowpal Wabbit")]
15-
[assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2012-2016, Yahoo! Inc. 2007-2012, and many individua" +
16-
"l contributors. All rights reserved")]
17-
[assembly: System.Runtime.InteropServices.ComVisible(false)]
18-
[assembly: System.CLSCompliant(false)]
19-
[assembly: System.Runtime.InteropServices.Guid("6a577997-af00-4ca0-8453-fdc8bbdf2a57")]
20-
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21-
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
22-
23-
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
// Runtime Version:4.0.30319.42000
5+
//
6+
// Changes to this file may cause incorrect behavior and will be lost if
7+
// the code is regenerated.
8+
// </auto-generated>
9+
//------------------------------------------------------------------------------
10+
11+
[assembly: System.Reflection.AssemblyTitle("Vowpal Wabbit")]
12+
[assembly: System.Reflection.AssemblyDescription("Vowpal Wabbit")]
13+
[assembly: System.Reflection.AssemblyCompany("Microsoft Corp")]
14+
[assembly: System.Reflection.AssemblyProduct("Vowpal Wabbit")]
15+
[assembly: System.Reflection.AssemblyCopyright("Copyright (C) Microsoft Corp 2012-2016, Yahoo! Inc. 2007-2012, and many individua" +
16+
"l contributors. All rights reserved")]
17+
[assembly: System.Runtime.InteropServices.ComVisible(false)]
18+
[assembly: System.CLSCompliant(false)]
19+
[assembly: System.Runtime.InteropServices.Guid("6a577997-af00-4ca0-8453-fdc8bbdf2a57")]
20+
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21+
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
22+
23+

cs/common/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.36366
4+
// Runtime Version:4.0.30319.42000
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
@@ -17,7 +17,7 @@
1717
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1818
[assembly: System.CLSCompliant(false)]
1919
[assembly: System.Runtime.InteropServices.Guid("091c7906-1f69-44d5-a15f-fb29847a68ef")]
20-
[assembly: System.Reflection.AssemblyVersion("8.3.0.5")]
21-
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.5")]
20+
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21+
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
2222

2323

cs/cs/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.36366
4+
// Runtime Version:4.0.30319.42000
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
@@ -17,7 +17,7 @@
1717
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1818
[assembly: System.CLSCompliant(false)]
1919
[assembly: System.Runtime.InteropServices.Guid("6a577997-af00-4ca0-8453-fdc8bbdf2a57")]
20-
[assembly: System.Reflection.AssemblyVersion("8.3.0.5")]
21-
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.5")]
20+
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21+
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
2222

2323

cs/cs_console/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.36366
4+
// Runtime Version:4.0.30319.42000
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
@@ -17,7 +17,7 @@
1717
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1818
[assembly: System.CLSCompliant(false)]
1919
[assembly: System.Runtime.InteropServices.Guid("c7c26e42-6d03-4fe5-943c-add2440f1e37")]
20-
[assembly: System.Reflection.AssemblyVersion("8.3.0.5")]
21-
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.5")]
20+
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21+
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
2222

2323

cs/cs_json/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.36366
4+
// Runtime Version:4.0.30319.42000
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
@@ -17,7 +17,7 @@
1717
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1818
[assembly: System.CLSCompliant(false)]
1919
[assembly: System.Runtime.InteropServices.Guid("8a34db14-bac2-474b-8102-be25ca5f2c55")]
20-
[assembly: System.Reflection.AssemblyVersion("8.3.0.5")]
21-
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.5")]
20+
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21+
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
2222

2323

cs/cs_parallel/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.36366
4+
// Runtime Version:4.0.30319.42000
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
@@ -17,7 +17,7 @@
1717
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1818
[assembly: System.CLSCompliant(false)]
1919
[assembly: System.Runtime.InteropServices.Guid("0bb98c1a-b25f-43a0-94b6-fed77f7e5cd8")]
20-
[assembly: System.Reflection.AssemblyVersion("8.3.0.5")]
21-
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.5")]
20+
[assembly: System.Reflection.AssemblyVersion("8.3.0.9")]
21+
[assembly: System.Reflection.AssemblyFileVersion("8.3.0.9")]
2222

2323

0 commit comments

Comments
 (0)