@datagrok/api-samples 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/statistics/pearson-correlation.js +39 -0
- package/scripts/ui/components/drop-down.js +9 -10
- package/test-console-output-1.log +126 -126
- package/test-console-output-2.log +60 -68
- package/test-console-output-3.log +99 -176
- package/test-console-output-4.log +41 -1006
- package/test-console-output-5.log +759 -634
- package/test-console-output-6.log +970 -0
- package/test-console-output-7.log +7 -0
- package/test-record-1.mp4 +0 -0
- package/test-record-2.mp4 +0 -0
- package/test-record-3.mp4 +0 -0
- package/test-record-4.mp4 +0 -0
- package/test-record-5.mp4 +0 -0
- package/test-record-6.mp4 +0 -0
- package/test-record-7.mp4 +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//name: Pearson
|
|
2
|
+
//description: Computes Pearson correlation for two numerical columns
|
|
3
|
+
//language: javascript
|
|
4
|
+
//input: dataframe df
|
|
5
|
+
//input: column c1
|
|
6
|
+
//input: column c2
|
|
7
|
+
//output: double corr
|
|
8
|
+
|
|
9
|
+
let a1 = c1.getRawData();
|
|
10
|
+
let a2 = c1.getRawData();
|
|
11
|
+
let n = 0;
|
|
12
|
+
let sumX = 0, sumY = 0;
|
|
13
|
+
let sumXX = 0, sumYY = 0;
|
|
14
|
+
let sumXY = 0;
|
|
15
|
+
|
|
16
|
+
for (let i = 0; i < c1.length; i++) {
|
|
17
|
+
const x = a1[i];
|
|
18
|
+
const y = a2[i];
|
|
19
|
+
|
|
20
|
+
if (x == null || y == null)
|
|
21
|
+
continue;
|
|
22
|
+
const xf = Number(x);
|
|
23
|
+
const yf = Number(y);
|
|
24
|
+
if (!Number.isFinite(xf) || !Number.isFinite(yf))
|
|
25
|
+
continue;
|
|
26
|
+
|
|
27
|
+
n++;
|
|
28
|
+
sumX += xf;
|
|
29
|
+
sumY += yf;
|
|
30
|
+
sumXX += xf * xf;
|
|
31
|
+
sumYY += yf * yf;
|
|
32
|
+
sumXY += xf * yf;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (n >= 2) {
|
|
36
|
+
const num = n * sumXY - sumX * sumY;
|
|
37
|
+
const den = Math.sqrt((n * sumXX - sumX * sumX) * (n * sumYY - sumY * sumY));
|
|
38
|
+
corr = den === 0 ? NaN : (num / den);
|
|
39
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
ui.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
grok.shell.newView('Drop-Down', [
|
|
2
|
+
ui.ribbonPanel([
|
|
3
|
+
ui.dropDown('Element', () => ui.div('Element')),
|
|
4
|
+
ui.dropDown('List', () => ui.list(['Element 1', 'Element 2', 'Element 3'])),
|
|
5
|
+
ui.dropDown('Menu', () => ui.popupMenu({
|
|
6
|
+
'Foo': () => grok.shell.info('foo'),
|
|
7
|
+
'Bar': () => {}
|
|
8
|
+
}, {show: false}).root)
|
|
9
|
+
])]);
|