-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathloadData.R
More file actions
102 lines (74 loc) · 3.13 KB
/
loadData.R
File metadata and controls
102 lines (74 loc) · 3.13 KB
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
library(Matrix)
acq <- read.table(file = "./data/reuters21578.10.training.acq.labels")
acq <- as.numeric(acq$V1)
acq <- acq - 1
corn <- read.table(file = "./data/reuters21578.10.training.corn.labels")
corn <- as.numeric(corn$V1)
corn <- corn - 1
crude <- read.table(file = "./data/reuters21578.10.training.crude.labels")
crude <- as.numeric(crude$V1)
crude <- crude - 1
earn <- read.table(file = "./data/reuters21578.10.training.earn.labels")
earn <- as.numeric(earn$V1)
earn <- earn - 1
grain <- read.table(file = "./data/reuters21578.10.training.grain.labels")
grain <- as.numeric(grain$V1)
grain <- grain - 1
interest <- read.table(file = "./data/reuters21578.10.training.interest.labels")
interest <- as.numeric(interest$V1)
interest <- interest - 1
money <- read.table(file = "./data/reuters21578.10.training.money-fx.labels")
money <- as.numeric(money$V1)
money <- money - 1
ship <- read.table(file = "./data/reuters21578.10.training.ship.labels")
ship <- as.numeric(ship$V1)
ship <- ship - 1
trade <- read.table(file = "./data/reuters21578.10.training.trade.labels")
trade <- as.numeric(trade$V1)
trade <- trade - 1
wheat <- read.table(file = "./data/reuters21578.10.training.wheat.labels")
wheat <- as.numeric(wheat$V1)
wheat <- wheat - 1
labelsTraining <- data.frame(acq, corn, crude, earn, grain,
interest, money, ship, trade, wheat)
t <- read.table(file = "./data/reuters21578.10.training.matrix")
datasetTraining <- sparseMatrix(t[,1], t[,2], x=t[, 3] <- 1)
acq <- read.table(file = "./data/reuters21578.10.test.acq.labels")
acq <- as.numeric(acq$V1)
acq <- acq - 1
corn <- read.table(file = "./data/reuters21578.10.test.corn.labels")
corn <- as.numeric(corn$V1)
corn <- corn - 1
crude <- read.table(file = "./data/reuters21578.10.test.crude.labels")
crude <- as.numeric(crude$V1)
crude <- crude - 1
earn <- read.table(file = "./data/reuters21578.10.test.earn.labels")
earn <- as.numeric(earn$V1)
earn <- earn - 1
grain <- read.table(file = "./data/reuters21578.10.test.grain.labels")
grain <- as.numeric(grain$V1)
grain <- grain - 1
interest <- read.table(file = "./data/reuters21578.10.test.interest.labels")
interest <- as.numeric(interest$V1)
interest <- interest - 1
money <- read.table(file = "./data/reuters21578.10.test.money-fx.labels")
money <- as.numeric(money$V1)
money <- money - 1
ship <- read.table(file = "./data/reuters21578.10.test.ship.labels")
ship <- as.numeric(ship$V1)
ship <- ship - 1
trade <- read.table(file = "./data/reuters21578.10.test.trade.labels")
trade <- as.numeric(trade$V1)
trade <- trade - 1
wheat <- read.table(file = "./data/reuters21578.10.test.wheat.labels")
wheat <- as.numeric(wheat$V1)
wheat <- wheat - 1
labelsTest <- data.frame(acq, corn, crude, earn, grain,
interest, money, ship, trade, wheat)
t <- read.table(file = "./data/reuters21578.10.test.matrix")
datasetTest <- sparseMatrix(t[,1], t[,2], x=t[, 3] <- 1)
rm(list = c("t", "acq", "corn", "crude", "earn", "grain",
"interest", "money", "ship", "trade", "wheat"))
## set number of (training) objects and features
numberOfObjects <- dim(datasetTraining)[1]
numberOfFeatures <- dim(datasetTraining)[2]