-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
269 lines (219 loc) · 7.41 KB
/
main.go
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
package main
import (
//"bufio"
//"encoding/csv"
"os"
"os/exec"
"fmt"
//"io"
"log"
"time"
)
func SendValue(s string, c chan string){
//send value through channel c
c <- s
}
func work(messages chan<- string) {
messages <- "golangcode.com"
}
func pythonCall(progName string, dataset string){
cmd := exec.Command("python3", progName, dataset)
cmd.Stdout = os.Stdout
cmd.Stderr = os. Stderr
log.Println(cmd.Run())
//time.Sleep(2 * time.Millisecond)
}
func main() {
//get input dataset location
cmd := exec.Command("python", "-c", "from workflow import userScript; print userScript.inputDataset")
//fmt.Println(cmd.Args)
out, err := cmd.CombinedOutput()
if err != nil { fmt.Println(err); }
//input dataset from disk
inputDataset := string(out)[:len(out)-1]
//fmt.Print(inputDataset)
//get output dataset location
cmd1 := exec.Command("python", "-c", "from workflow import userScript; print userScript.outputDataset")
//fmt.Println(cmd1.Args)
out1, err1 := cmd1.CombinedOutput()
if err1 != nil { fmt.Println(err1); }
//input dataset from disk
outputDataset := string(out1)[:len(out1)-1]
//fmt.Print(outputDataset)
///////////////////////////*****************SELECTION************************////////////////////////
//select user defined cols
go pythonCall("workflow/selection/selectUserDefinedColumns.py", inputDataset)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Select User Defined Columns Complete")
//channel
channel := make(chan string)
defer close(channel)
go SendValue(outputDataset, channel)
output := <-channel
time.Sleep(10000 * time.Millisecond)
///////////////////////////*****************CLEANING************************////////////////////////
//drop unique cols
go pythonCall("workflow/cleaning/dropUniqueColumns.py", output)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Drop unique columns complete")
//channel
channel1 := make(chan string)
defer close(channel1)
go SendValue(outputDataset, channel1)
output1 := <-channel1
time.Sleep(10000 * time.Millisecond)
//drop one value cols
go pythonCall("workflow/cleaning/dropOneValueColumns.py", output1)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Drop one value columns complete")
//channel
channel2 := make(chan string)
defer close(channel2)
go SendValue(outputDataset, channel2)
output2 := <-channel2
time.Sleep(10000 * time.Millisecond)
//Drop user defined cols
go pythonCall("workflow/cleaning/dropUserDefinedColumns.py", output2)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Drop user defined columns complete")
//channel
channel3 := make(chan string)
defer close(channel3)
go SendValue(outputDataset, channel3)
output3 := <-channel3
time.Sleep(10000 * time.Millisecond)
//#drop columns according to user defined empty value percentage
go pythonCall("workflow/cleaning/dropColumnsCriteria.py", output3)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Drop user defined rows complete")
/*//channel
channel4 := make(chan string)
defer close(channel4)
go SendValue(outputDataset, channel4)
output4 := <-channel4
fmt.Println("Drop columns criteria complete")
time.Sleep(10000 * time.Millisecond)
//#drop user defined rows
go pythonCall("workflow/cleaning/dropUserDefinedRows.py", output4)
time.Sleep(10000 * time.Millisecond)
*/
//channel
channel5 := make(chan string)
defer close(channel5)
go SendValue(outputDataset, channel5)
output5 := <-channel5
time.Sleep(10000 * time.Millisecond)
//drop rows according to user defined empty value percentage
go pythonCall("workflow/cleaning/dropRowsCriteria.py", output5)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Drop row criteria complete")
//channel
channel6 := make(chan string)
defer close(channel6)
go SendValue(outputDataset, channel6)
output6 := <-channel6
time.Sleep(10000 * time.Millisecond)
//#remove duplicate rows
go pythonCall("workflow/cleaning/removeDuplicateRows.py", output6)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Remove duplicate rows complete")
//channel
channel7 := make(chan string)
defer close(channel7)
go SendValue(outputDataset, channel7)
output7 := <-channel7
time.Sleep(10000 * time.Millisecond)
//missing value interpolation
go pythonCall("workflow/cleaning/missingValuesInterpolate.py", output7)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Missing values interpolate complete")
//channel
channel8 := make(chan string)
defer close(channel8)
go SendValue(outputDataset, channel8)
output8 := <-channel8
time.Sleep(10000 * time.Millisecond)
//mode for user defined columns
go pythonCall("workflow/cleaning/missingValuesMode.py", output8)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Missing values mode complete")
//channel
channel9 := make(chan string)
defer close(channel9)
go SendValue(outputDataset, channel9)
output9 := <-channel9
time.Sleep(10000 * time.Millisecond)
///////////////////////////*****************TRANSFORMATION************************////////////////////////
//standardize user defined columns
go pythonCall("workflow/transformation/standardize.py", output9)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Standardize complete")
//channel
channel10 := make(chan string)
defer close(channel10)
go SendValue(outputDataset, channel10)
output10 := <-channel10
time.Sleep(10000 * time.Millisecond)
//rescale user defined Columns
go pythonCall("workflow/transformation/rescale.py", output10)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Rescaling complete")
//channel
channel11 := make(chan string)
defer close(channel11)
go SendValue(outputDataset, channel11)
output11 := <-channel11
time.Sleep(10000 * time.Millisecond)
//binarize user defined Columns
go pythonCall("workflow/transformation/binarize.py", output11)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Binarization complete")
//channel
channel12 := make(chan string)
defer close(channel12)
go SendValue(outputDataset, channel12)
output12 := <-channel12
time.Sleep(10000 * time.Millisecond)
//encoding user defined Columns
go pythonCall("workflow/transformation/encoding.py", output12)
time.Sleep(10000 * time.Millisecond)
fmt.Println("Encoding complete")
//channel
channel13 := make(chan string)
defer close(channel13)
go SendValue(outputDataset, channel13)
output13 := <-channel13
time.Sleep(10000 * time.Millisecond)
///////////////////////////*****************MINING************************////////////////////////
/////////////////KMEANS////////////////
go pythonCall("workflow/mining/kmeans.py", output13)
//time.Sleep(120000 * time.Millisecond)
fmt.Println("Kmeans complete")
//////////////////LinearRegression/////////////////
go pythonCall("workflow/mining/linearRegression.py", output13)
fmt.Println("Linear Regression complete")
time.Sleep(60000 * time.Millisecond)
}
/*
func csvWriter(){
csvfile, err := os.Create("test.csv")
if err != nil {
log.Fatalf("failed creating file: %s", err)
}
csvwriter := csv.NewWriter(csvfile)
f, _ := os.Open("/home/rajini/Desktop/go/propertyData.csv")
r := csv.NewReader(bufio.NewReader(f))
for {
record, err := r.Read()
if err == io.EOF {
break
}
go SendValue(record,instances)
instance := <-instances
fmt.Println(instance)
_ = csvwriter.Write(instance)
//fmt.Printf("\n")
}
csvwriter.Flush()
csvfile.Close()
}*/