-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKhamis_Rochie_Height Prediction Model.js
More file actions
96 lines (92 loc) · 3.49 KB
/
Khamis_Rochie_Height Prediction Model.js
File metadata and controls
96 lines (92 loc) · 3.49 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
var data = [
{
4: [-0.087235, 1.23812, 0.50286, -10.2567],
4.5: [-0.074454, 1.15964, 0.52887, -10.719],
5: [-0.064778, 1.10674, 0.53919, -11.0213],
5.5: [-0.05776, 1.0748, 0.53691, -11.1556],
6: [-0.052947, 1.05923, 0.52513, -11.1138],
6.5: [-0.049892, 1.05542, 0.50692, -11.0221],
7: [-0.048144, 1.05877, 0.48538, -10.9984],
7.5: [-0.047256, 1.06467, 0.46361, -11.0214],
8: [-0.046778, 1.06853, 0.44469, -11.0696],
8.5: [-0.046261, 1.06572, 0.43171, -11.122],
9: [-0.045254, 1.05166, 0.42776, -11.1571],
9.5: [-0.043311, 1.02174, 0.43593, -11.1405],
10: [-0.039981, 0.97135, 0.45932, -11.038],
10.5: [-0.034814, 0.89589, 0.50101, -10.8286],
11: [-0.02905, 0.81239, 0.54781, -10.4917],
11.5: [-0.024167, 0.74134, 0.58409, -10.0065],
12: [-0.020076, 0.68325, 0.60927, -9.3522],
12.5: [-0.016681, 0.63869, 0.62279, -8.6055],
13: [-0.013895, 0.60818, 0.62407, -7.8632],
13.5: [-0.011624, 0.59228, 0.61253, -7.1348],
14: [-0.009776, 0.59151, 0.58762, -6.4299],
14.5: [-0.008261, 0.60643, 0.54875, -5.7578],
15: [-0.006988, 0.63757, 0.49536, -5.1282],
15.5: [-0.005863, 0.68548, 0.42687, -4.5092],
16: [-0.004795, 0.75069, 0.34271, -3.9292],
16.5: [-0.003695, 0.83375, 0.24231, -3.4873],
17: [-0.00247, 0.9352, 0.1251, -3.283],
17.5: [-0.001027, 1.05558, -0.0095, -3.4156],
},
{
4: [-0.19435, 1.24768, 0.44774, -8.1325],
4.5: [-0.18519, 1.22177, 0.41381, -6.47656],
5: [-0.1753, 1.19932, 0.38467, -5.13583],
5.5: [-0.16484, 1.1788, 0.36039, -4.13791],
6: [-0.154, 1.15866, 0.34105, -3.51039],
6.5: [-0.14294, 1.13737, 0.32672, -3.14322],
7: [-0.13184, 1.11342, 0.31748, -2.87645],
7.5: [-0.12086, 1.08525, 0.3134, -2.66291],
8: [-0.11019, 1.05135, 0.31457, -2.45559],
8.5: [-0.09999, 1.01018, 0.32105, -2.20728],
9: [-0.09044, 0.9602, 0.33291, -1.87098],
9.5: [-0.08171, 0.89989, 0.35025, -1.0633],
10: [-0.07397, 0.82771, 0.37312, 0.33468],
10.5: [-0.06739, 0.74213, 0.40161, 1.97366],
11: [-0.06136, 0.67173, 0.42042, 3.50436],
11.5: [-0.05518, 0.6415, 0.41686, 4.57747],
12: [-0.04894, 0.64452, 0.3949, 4.84365],
12.5: [-0.04272, 0.67386, 0.3585, 4.27869],
13: [-0.03661, 0.7226, 0.31163, 3.21417],
13.5: [-0.03067, 0.78383, 0.25826, 1.83456],
14: [-0.025, 0.85062, 0.20235, 0.32425],
14.5: [-0.01967, 0.91605, 0.14787, -1.13224],
15: [-0.01477, 0.97319, 0.0988, -2.35055],
15.5: [-0.01037, 1.01514, 0.05909, -3.10326],
16: [-0.00655, 1.03496, 0.03272, -3.17885],
16.5: [-0.0034, 1.02573, 0.02364, -2.41657],
17: [-0.001, 0.98054, 0.03584, -0.65579],
17.5: [0.00057, 0.89246, 0.07327, 2.26429],
},
];
// function description 0 for male and 1 for female
function heightPredictor(age, weight, height, m_height, f_height, gender) {
//base case
if (age === 18) {
return height;
} else {
//metric conversion
// cm to inches
// kg to pounds
// weight = weight * 2.20462262;
// height = height / 2.54;
// m_height = m_height / 2.54;
// f_height = f_height / 2.54;
//Getting data
d = data[gender][age];
//Performing calculations based upon the model
result =
d[0] * weight + d[1] * height + d[2] * ((m_height + f_height) / 2) + d[3];
if (result > height) {
res = result;
} else {
res = height;
}
//metric conversion
//inches to cm, pounds to kg
// result_in_cm = res * 2.54;
return res
}
}
console.log(heightPredictor(5, 40, 44, 65, 70, 0));