-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbasics.py
62 lines (55 loc) · 1.28 KB
/
basics.py
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
# -*- coding: utf-8 -*-
from weka_porter import Porter
porter = Porter(language='java')
result = porter.port('j48_tree.txt', method_name='classify')
print(result)
"""
public static String classify(String outlook, boolean windy, double humidity) {
if (outlook.equals("sunny")) {
if (humidity <= 75) {
return "yes";
}
else if (humidity > 75) {
return "no";
}
}
else if (outlook.equals("overcast")) {
return "yes";
}
else if (outlook.equals("rainy")) {
if (windy == true) {
return "no";
}
else if (windy == false) {
return "yes";
}
}
return null;
}
"""
result = porter.port('j48_tree_numeric.txt', method_name='classify_num')
print(result)
"""
public static int classify_num(String outlook, boolean windy, double humidity) {
if (outlook.equals("sunny")) {
if (humidity <= 75) {
return 1;
}
else if (humidity > 75) {
return -1;
}
}
else if (outlook.equals("overcast")) {
return 1;
}
else if (outlook.equals("rainy")) {
if (windy == true) {
return -1;
}
else if (windy == false) {
return 1;
}
}
return null;
}
"""