sdbrgo commited on
Commit
69c3447
·
verified ·
1 Parent(s): de6c8d3

Update phase/interpret.py

Browse files

modified entire interface; defined state rules for every component

Files changed (1) hide show
  1. phase/interpret.py +42 -21
phase/interpret.py CHANGED
@@ -1,25 +1,46 @@
1
- def assign_typology(sorted_components, high_th=0.4, th=0.2):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- high_impact = []
4
- medium_impact = []
5
- low_impact = []
 
 
6
 
7
- for component, data in sorted_components.items():
8
- entry = {
9
- "component": component,
10
- "value": data["value"],
11
- "description": data.get("description", "")
12
- }
13
 
14
- if abs(data["value"]) >= high_th:
15
- high_impact.append(entry)
16
- elif abs(data["value"]) >= th:
17
- medium_impact.append(entry)
18
- else:
19
- low_impact.append(entry)
 
 
20
 
21
- return {
22
- "high": high_impact,
23
- "medium": medium_impact,
24
- "low": low_impact
25
- }
 
1
+ def assign_typology(components, high_th=0.4, th=0.2):
2
+
3
+ # define state rules for every components
4
+ STATE_RULES = {
5
+ "PCR (Participation Coverage Ratio)": [
6
+ (0.5, "Low Alert"),
7
+ (0.2, "Medium Alert"),
8
+ (0.0, "High Alert")
9
+ ],
10
+ "SPI-A (Silent Participation Inference - Silent Non-Adoption)": [
11
+ (0.7, "High Alert"),
12
+ (0.3, "Medium Alert"),
13
+ (0.0, "Low Alert")
14
+ ],
15
+ "SPI-B (Silent Participation Inference - Silent Adoption)": [
16
+ (0.5, "High Alert"),
17
+ (0.2, "Medium Alert"),
18
+ (0.0, "Low Alert")
19
+ ],
20
+ "PEG (Participation-to-Expression Gap)": [
21
+ (0.6, "High Alert"),
22
+ (0.3, "Medium Alert"),
23
+ (0.0, "Low Alert")
24
+ ]
25
+ }
26
 
27
+ buckets = {
28
+ "High Alert": [],
29
+ "Medium Alert": [],
30
+ "Low Alert": []
31
+ }
32
 
33
+ for component, data in components.items():
34
+ value = data["Value"]
35
+ description = data.get("Description", "")
 
 
 
36
 
37
+ for threshold, state in STATE_RULES[component]:
38
+ if value >= threshold:
39
+ buckets[state].append({
40
+ "Component": component,
41
+ "Value": value,
42
+ "Description": description
43
+ })
44
+ break
45
 
46
+ return buckets