-
Notifications
You must be signed in to change notification settings - Fork 0
/
module_regression.php
176 lines (152 loc) · 5.46 KB
/
module_regression.php
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
<?php
include "connection.php";
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- meta settings -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Riznel Baldazo">
<!-- libraries -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" type="text/css" href="w3.css?v=<?php echo time(); ?>">
<link rel="stylesheet" type="text/css" href="riz.css?v=<?php echo time(); ?>">
</head>
<body>
<div class="container-fluid">
<div class="row">
<!-- ---------------------- Navigation Bar ---------------------------- -->
<div class="col-md-1" style="height: 100vh;">
<div style="width: 60px; height: 100vh; background: linear-gradient(240deg, rgba(255,255,255,0) 0%, rgba(61,202,255,0.14609593837535018) 30%, rgba(51,199,255,0.3477766106442577) 40%, rgba(41,196,255,0.6110819327731092) 50%, rgba(18,190,255,1) 69%, rgba(37,181,236,1) 70%, rgba(13,142,176,1) 90%, rgba(10,96,124,1) 100%); float: left; position: fixed; left: 0;">
<center>
<div style="margin-top: 50px;">
<button data-toggle="modal" data-target="#logout_modal" style="border: none; background-color: transparent; margin-top: 20px;">
<i class="material-icons riz-nav-inactive" style="font-size:24px;">arrow_back</i>
</button>
<button onclick="window.location.href='/ground_griffin/module_frequency_distribution.php'" style="border: none; background-color: transparent; margin-top: 20px;">
<i class="material-icons riz-nav-inactive" style="font-size:24px;">group</i>
</button>
<div style="border: none; background-color: transparent; margin-top: 20px;">
<i class="material-icons riz-nav-active" style="font-size:24px;">trending_up</i>
</div>
</div>
</center>
</div>
</div>
<div id="logout_modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<center>
<div>Continue to logout?</div>
<br/>
<button style="width: 100px;" class="btn btn-info" onclick="window.location.href='/ground_griffin/index.php'">Yes</button>
</center>
</div>
</div>
</div>
</div>
<!-- ---------------------------- Body ---------------------------- -->
<div class="col-md-11 m-0">
<div class="w3-card" style="padding: 16px 24px; margin-top: 20px; width: 300px;">
<div>Years Covered: <span id="years_covered"> 2020 to 2024 <span></div>
</div>
<div class="w3-card" style="padding: 16px 24px; margin-top: 20px; width: 900px;">
<canvas id="regression_canvas"></canvas>
</div>
<script type="text/javascript">
$(document).ready(function() {
$.post("dataconnect_regression.php", {
},
function(data) {
data = JSON.parse(data);
var ethnic_diversity = data[0];
var count_impact = data[1];
// mean of X
var sum_eth_div = 0;
for (eth_div of ethnic_diversity) {
sum_eth_div += eth_div;
}
var mean_eth_div = sum_eth_div/ethnic_diversity.length;
// mean of Y
var sum_cnt_imp = 0;
for (cnt_imp of count_impact) {
sum_cnt_imp += cnt_imp;
}
var mean_cnt_imp = sum_cnt_imp/count_impact.length;
// number of values
var n = ethnic_diversity.length;
// calculating slope and y-intercept
var numer = 0;
var denom = 0;
for (i = 0; i < n; i++) {
numer += (ethnic_diversity[i] - mean_eth_div) * (count_impact[i] - mean_cnt_imp);
denom += (ethnic_diversity[i] - mean_eth_div) ** 2;
}
var slope = numer / denom;
var intercept = mean_cnt_imp - (slope * mean_eth_div);
var regression_canvas = document.getElementById("regression_canvas").getContext("2d");
var regression_chart = new Chart(regression_canvas, {
type: "scatter",
data: {
datasets: [{
backgroundColor: "#448AFF",
borderColor: "#448AFF",
label: "data points",
data: [{
x: ethnic_diversity[0],
y: count_impact[0]
}, {
x: ethnic_diversity[1],
y: count_impact[1]
}, {
x: ethnic_diversity[2],
y: count_impact[2]
}, {
x: ethnic_diversity[3],
y: count_impact[3]
}, {
x: ethnic_diversity[4],
y: count_impact[4]
}]
},{
borderColor: "#B0BEC5",
radius: 0,
backgroundColor: "rgba(0,0,0,0)",
showLine: true,
label: "line of best fit",
type: "line",
data: [{
x: 51.90,
y: 20000
}, {
x: 33.63,
y: 25000
}, {
x: 15.37,
y: 30000
}, {
x: -2.90,
y: 35000
}]
}
]}
});
}
);
});
</script>
<!-- end of col-11 -->
</div>
</div>
</div>
</body>