Update phase/interpret.py
Browse filesmodified entire interface; defined state rules for every component
- phase/interpret.py +42 -21
phase/interpret.py
CHANGED
|
@@ -1,25 +1,46 @@
|
|
| 1 |
-
def assign_typology(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
for component, data in
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
"value": data["value"],
|
| 11 |
-
"description": data.get("description", "")
|
| 12 |
-
}
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|