@decidables/detectable-elements 0.1.1 → 0.2.0
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/CHANGELOG.md +44 -0
- package/README.md +128 -5
- package/lib/detectableElements.esm.js +742 -367
- package/lib/detectableElements.esm.js.map +1 -1
- package/lib/detectableElements.esm.min.js +215 -129
- package/lib/detectableElements.esm.min.js.map +1 -1
- package/lib/detectableElements.umd.js +744 -366
- package/lib/detectableElements.umd.js.map +1 -1
- package/lib/detectableElements.umd.min.js +220 -134
- package/lib/detectableElements.umd.min.js.map +1 -1
- package/package.json +3 -3
- package/src/components/detectable-control.js +7 -6
- package/src/components/detectable-response.js +26 -11
- package/src/components/detectable-table.js +30 -13
- package/src/components/rdk-task.js +4 -6
- package/src/components/roc-space.js +5 -7
- package/src/components/sdt-model.js +13 -15
- package/src/equations/hfa2ppv.js +121 -0
- package/src/equations/hmfacr2acc.js +1 -1
- package/src/equations/index.js +2 -0
- package/src/equations/mcr2fomr.js +121 -0
- package/src/equations/sdt-equation.js +15 -0
- package/src/examples/index.js +1 -0
- package/src/examples/multiple.js +76 -0
- package/src/examples/sdt-example.js +2 -6
- package/src/examples/unequal.js +4 -6
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
|
|
2
|
+
import {html} from 'lit';
|
|
3
|
+
|
|
4
|
+
import '@decidables/decidables-elements/spinner';
|
|
5
|
+
import SDTMath from '@decidables/detectable-math';
|
|
6
|
+
|
|
7
|
+
import SDTEquation from './sdt-equation';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
SDTEquationMCr2Fomr element
|
|
11
|
+
<sdt-equation-mcr2fomr>
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
Hits; Misses; Hit Rate;
|
|
15
|
+
*/
|
|
16
|
+
export default class SDTEquationMCr2Fomr extends SDTEquation {
|
|
17
|
+
static get properties() {
|
|
18
|
+
return {
|
|
19
|
+
m: {
|
|
20
|
+
attribute: 'misses',
|
|
21
|
+
type: Number,
|
|
22
|
+
reflect: true,
|
|
23
|
+
},
|
|
24
|
+
cr: {
|
|
25
|
+
attribute: 'correct-rejections',
|
|
26
|
+
type: Number,
|
|
27
|
+
reflect: true,
|
|
28
|
+
},
|
|
29
|
+
fomr: {
|
|
30
|
+
attribute: false,
|
|
31
|
+
type: Number,
|
|
32
|
+
reflect: false,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
this.m = 0;
|
|
40
|
+
this.cr = 0;
|
|
41
|
+
this.alignState();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
alignState() {
|
|
45
|
+
this.fomr = SDTMath.mCr2Fomr(this.m, this.cr);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
sendEvent() {
|
|
49
|
+
this.dispatchEvent(new CustomEvent('sdt-equation-mcr2fomr-change', {
|
|
50
|
+
detail: {
|
|
51
|
+
m: this.m,
|
|
52
|
+
cr: this.cr,
|
|
53
|
+
fomr: this.fomr,
|
|
54
|
+
},
|
|
55
|
+
bubbles: true,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
mInput(event) {
|
|
60
|
+
this.m = parseInt(event.target.value, 10);
|
|
61
|
+
this.alignState();
|
|
62
|
+
this.sendEvent();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
crInput(event) {
|
|
66
|
+
this.cr = parseInt(event.target.value, 10);
|
|
67
|
+
this.alignState();
|
|
68
|
+
this.sendEvent();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
render() {
|
|
72
|
+
this.alignState();
|
|
73
|
+
let m;
|
|
74
|
+
let cr;
|
|
75
|
+
let fomr;
|
|
76
|
+
if (this.numeric) {
|
|
77
|
+
m = html`
|
|
78
|
+
<decidables-spinner class="m" ?disabled=${!this.interactive} min="0" .value="${this.m}" @input=${this.mInput.bind(this)}>
|
|
79
|
+
<var>Misses</var>
|
|
80
|
+
</decidables-spinner>
|
|
81
|
+
`;
|
|
82
|
+
cr = html`
|
|
83
|
+
<decidables-spinner class="cr" ?disabled=${!this.interactive} min="0" .value="${this.cr}" @input=${this.crInput.bind(this)}>
|
|
84
|
+
<var>Correct Rejections</var>
|
|
85
|
+
</decidables-spinner>
|
|
86
|
+
`;
|
|
87
|
+
fomr = html`
|
|
88
|
+
<decidables-spinner class="fomr" disabled min="0" max="1" step=".001" .value="${+this.fomr.toFixed(3)}">
|
|
89
|
+
<var>False Omission Rate</var>
|
|
90
|
+
</decidables-spinner>
|
|
91
|
+
`;
|
|
92
|
+
} else {
|
|
93
|
+
m = html`<var class="m">Misses</var>`;
|
|
94
|
+
cr = html`<var class="cr">Correct Rejections</var>`;
|
|
95
|
+
fomr = html`<var class="fomr">False Omission Rate</var>`;
|
|
96
|
+
}
|
|
97
|
+
return html`
|
|
98
|
+
<div class="holder">
|
|
99
|
+
<table class="equation">
|
|
100
|
+
<tbody>
|
|
101
|
+
<tr>
|
|
102
|
+
<td rowspan="2">
|
|
103
|
+
${fomr}<span class="equals">=</span>
|
|
104
|
+
</td>
|
|
105
|
+
<td class="underline">
|
|
106
|
+
${m}
|
|
107
|
+
</td>
|
|
108
|
+
</tr>
|
|
109
|
+
<tr>
|
|
110
|
+
<td>
|
|
111
|
+
${m}<span class="plus">+</span>${cr}
|
|
112
|
+
</td>
|
|
113
|
+
</tr>
|
|
114
|
+
</tbody>
|
|
115
|
+
</table>
|
|
116
|
+
</div>
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
customElements.define('sdt-equation-mcr2fomr', SDTEquationMCr2Fomr);
|
|
@@ -45,6 +45,7 @@ export default class SDTEquation extends DetectableElement {
|
|
|
45
45
|
/* Overall <table> */
|
|
46
46
|
.equation {
|
|
47
47
|
text-align: center;
|
|
48
|
+
white-space: nowrap;
|
|
48
49
|
|
|
49
50
|
border-collapse: collapse;
|
|
50
51
|
|
|
@@ -64,6 +65,10 @@ export default class SDTEquation extends DetectableElement {
|
|
|
64
65
|
font-style: normal;
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
var {
|
|
69
|
+
border-radius: var(---border-radius);
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
.tight {
|
|
68
73
|
padding: 0;
|
|
69
74
|
}
|
|
@@ -89,6 +94,8 @@ export default class SDTEquation extends DetectableElement {
|
|
|
89
94
|
padding: 0.125rem 0.375rem 0.375rem;
|
|
90
95
|
|
|
91
96
|
vertical-align: middle;
|
|
97
|
+
|
|
98
|
+
border-radius: var(---border-radius);
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
.bottom {
|
|
@@ -112,6 +119,14 @@ export default class SDTEquation extends DetectableElement {
|
|
|
112
119
|
background: var(---color-fa-light);
|
|
113
120
|
}
|
|
114
121
|
|
|
122
|
+
.ppv {
|
|
123
|
+
background: var(---color-present-light);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.fomr {
|
|
127
|
+
background: var(---color-absent-light);
|
|
128
|
+
}
|
|
129
|
+
|
|
115
130
|
.acc {
|
|
116
131
|
background: var(---color-acc-light);
|
|
117
132
|
}
|
package/src/examples/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export {default as SDTExampleDoubleInteractive} from './double-interactive';
|
|
|
3
3
|
export {default as SDTExampleHuman} from './human';
|
|
4
4
|
export {default as SDTExampleInteractive} from './interactive';
|
|
5
5
|
export {default as SDTExampleModel} from './model';
|
|
6
|
+
export {default as SDTExampleMultiple} from './multiple';
|
|
6
7
|
export {default as SDTExampleUnequal} from './unequal';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
|
|
2
|
+
import DecidablesConverterArray from '@decidables/decidables-elements/converter-array';
|
|
3
|
+
|
|
4
|
+
import SDTExample from './sdt-example';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
SDTExampleMulti element
|
|
8
|
+
<sdt-example-multi>
|
|
9
|
+
*/
|
|
10
|
+
export default class SDTExampleMultiple extends SDTExample {
|
|
11
|
+
static get properties() {
|
|
12
|
+
return {
|
|
13
|
+
variable: {
|
|
14
|
+
attribute: 'variable',
|
|
15
|
+
type: String,
|
|
16
|
+
reflect: true,
|
|
17
|
+
},
|
|
18
|
+
values: {
|
|
19
|
+
attribute: 'values',
|
|
20
|
+
converter: DecidablesConverterArray,
|
|
21
|
+
reflect: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.variables = ['d', 'c'];
|
|
29
|
+
this.variable = 'd';
|
|
30
|
+
this.values = [0, 1];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
firstUpdated(/* changedProperties */) {
|
|
34
|
+
this.detectableControl = this.querySelector('detectable-control');
|
|
35
|
+
this.rocSpace = this.querySelector('roc-space');
|
|
36
|
+
this.sdtModel = this.querySelector('sdt-model');
|
|
37
|
+
|
|
38
|
+
if (this.detectableControl) {
|
|
39
|
+
this.detectableControl.addEventListener('detectable-control-z-roc', (event) => {
|
|
40
|
+
this.rocSpace.zRoc = event.detail.zRoc;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (this.rocSpace) {
|
|
45
|
+
this.rocSpace.setWithSDT(1, 0, 'default', '', 1);
|
|
46
|
+
if (this.variable === 'd') {
|
|
47
|
+
this.values.forEach((d, index) => {
|
|
48
|
+
this.rocSpace.setWithSDT(d, this.sdtModel.c, `point${index}`, index + 1, this.sdtModel.s);
|
|
49
|
+
});
|
|
50
|
+
} else if (this.variable === 'c') {
|
|
51
|
+
this.values.forEach((c, index) => {
|
|
52
|
+
this.rocSpace.setWithSDT(this.sdtModel.d, c, `point${index}`, index + 1, this.sdtModel.s);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (this.sdtModel) {
|
|
58
|
+
this.sdtModel.addEventListener('sdt-model-change', (event) => {
|
|
59
|
+
if (this.rocSpace) {
|
|
60
|
+
this.rocSpace.setWithSDT(event.detail.d, event.detail.c, 'default', '', event.detail.s);
|
|
61
|
+
if (this.variable === 'd') {
|
|
62
|
+
this.values.forEach((d, index) => {
|
|
63
|
+
this.rocSpace.setWithSDT(d, event.detail.c, `point${index}`, index + 1, event.detail.s);
|
|
64
|
+
});
|
|
65
|
+
} else if (this.variable === 'c') {
|
|
66
|
+
this.values.forEach((c, index) => {
|
|
67
|
+
this.rocSpace.setWithSDT(event.detail.d, c, `point${index}`, index + 1, event.detail.s);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
customElements.define('sdt-example-multiple', SDTExampleMultiple);
|
|
@@ -13,12 +13,8 @@ export default class SDTExample extends DetectableElement {
|
|
|
13
13
|
super.styles,
|
|
14
14
|
css`
|
|
15
15
|
:host {
|
|
16
|
-
---border: var(--border, 1px solid var(---color-border));
|
|
17
16
|
display: inline-block;
|
|
18
17
|
|
|
19
|
-
/* This makes IE11 happy */
|
|
20
|
-
width: 100%;
|
|
21
|
-
|
|
22
18
|
margin-bottom: 1rem;
|
|
23
19
|
}
|
|
24
20
|
|
|
@@ -37,7 +33,7 @@ export default class SDTExample extends DetectableElement {
|
|
|
37
33
|
padding: 0.625rem;
|
|
38
34
|
|
|
39
35
|
border: var(---border);
|
|
40
|
-
border-radius:
|
|
36
|
+
border-radius: var(---border-radius);
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
.body ::slotted(*) {
|
|
@@ -63,7 +59,7 @@ export default class SDTExample extends DetectableElement {
|
|
|
63
59
|
];
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
render() {
|
|
62
|
+
render() { /* eslint-disable-line class-methods-use-this */
|
|
67
63
|
return html`
|
|
68
64
|
<div class="holder">
|
|
69
65
|
<div class="body">
|
package/src/examples/unequal.js
CHANGED
|
@@ -20,15 +20,13 @@ export default class SDTExampleUnequal extends SDTExample {
|
|
|
20
20
|
|
|
21
21
|
if (this.rocSpace) {
|
|
22
22
|
this.rocSpace.setWithSDT(1, 0, 'default', '', 1); // Set 'default' to equal variance for contours
|
|
23
|
+
|
|
24
|
+
d3.range(-1.5, 1.6, 0.5).forEach((c, index) => {
|
|
25
|
+
this.rocSpace.setWithSDT(this.sdtModel.d, c, `point${index}`, '', this.sdtModel.s);
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
if (this.sdtModel) {
|
|
26
|
-
if (this.rocSpace) {
|
|
27
|
-
d3.range(-1.5, 1.6, 0.5).forEach((c, index) => {
|
|
28
|
-
this.rocSpace.setWithSDT(this.sdtModel.d, c, `point${index}`, '', this.sdtModel.s);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
30
|
this.sdtModel.addEventListener('sdt-model-change', (event) => {
|
|
33
31
|
if (this.rocSpace) {
|
|
34
32
|
d3.range(-1.5, 1.6, 0.5).forEach((c, index) => {
|