-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample.js
More file actions
50 lines (42 loc) · 1.83 KB
/
example.js
File metadata and controls
50 lines (42 loc) · 1.83 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
var AdaBoost = require('./AdaBoost');
(function () {
'use strict';
var trainingData = [
["Coughing", "Male", "Adult", "Discharged"],
["Coughing", "Female", "Teen", "Discharged"],
["Headache", "Male", "Child", "Discharged"],
["Headache", "Male", "Teen", "Discharged"],
["Hiccups", "Female", "Adult", "Discharged"],
["Sneezing", "Male", "Teen", "Discharged"],
["Sneezing", "Female", "Child", "Admitted"],
["Sneezing", "Male", "Child", "Admitted"],
["Hiccups", "Female", "Teen", "Admitted"],
["Coughing", "Female", "Adult", "Admitted"],
["Coughing", "Male", "Child", "Admitted"]
];
var adaBoost = new AdaBoost(trainingData, "Discharged");
var vote = adaBoost.predict(["Coughing", "Male", "Child"], true);
console.log("The final vote is " + vote);
console.log("The person will most likely be " + (vote > 1 ? "Discharged" : "Admitted"));
console.log("");
// The final vote is -1.7181763612259795
// The person will most likely be Admitted
vote = adaBoost.predict(["Headache", "Female", "Child"]);
console.log("The final vote is " + vote);
console.log("The person will most likely be " + (vote > 1 ? "Discharged" : "Admitted"));
console.log("");
// The final vote is 1.60653649762956
// The person will most likely be Discharged
vote = adaBoost.predict(["Hiccups", "Female", "Adult"]);
console.log("The final vote is " + vote);
console.log("The person will most likely be " + (vote > 1 ? "Discharged" : "Admitted"));
console.log("");
// The final vote is -0.0843346278612036 true
// The person will most likely be Admitted
vote = adaBoost.predict(["Headache", "", "Child"]);
console.log("The final vote is " + vote);
console.log("The person will most likely be " + (vote > 1 ? "Discharged" : "Admitted"));
console.log("");
// The final vote is 2.3552095483256945 true
// The person will most likely be Discharged
})();