Upload dual lifecycle next-activity model
Browse files- .gitattributes +2 -0
- README.md +74 -0
- best_model.keras +3 -0
- history.json +35 -0
- metadata.json +79 -0
- metrics.json +13 -0
- model.keras +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
best_model.keras filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
model.keras filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: tf-keras
|
| 3 |
+
tags:
|
| 4 |
+
- process-mining
|
| 5 |
+
- next-activity-prediction
|
| 6 |
+
- sequence-modeling
|
| 7 |
+
- tensorflow
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# next_activity_prediction_lifecycle_dual
|
| 11 |
+
|
| 12 |
+
Dual-head next-event model that predicts:
|
| 13 |
+
- next activity (`concept:name`)
|
| 14 |
+
- next lifecycle transition (`lifecycle:transition`)
|
| 15 |
+
|
| 16 |
+
This repository was exported from:
|
| 17 |
+
`next_activity_prediction_lifecycle_dual\next_activity_prediction_lifecycle_dual\models\start_complete\baseline`
|
| 18 |
+
|
| 19 |
+
## Included files
|
| 20 |
+
|
| 21 |
+
- `model.keras`
|
| 22 |
+
- `metadata.json`
|
| 23 |
+
- `metrics.json` (if available)
|
| 24 |
+
- `history.json` (if available)
|
| 25 |
+
|
| 26 |
+
## Metrics
|
| 27 |
+
|
| 28 |
+
- Activity accuracy: `0.8443847963680949`
|
| 29 |
+
- Activity macro-F1: `0.6984303181387901`
|
| 30 |
+
- Lifecycle accuracy: `0.8857407959704411`
|
| 31 |
+
- Lifecycle macro-F1: `0.8672618282920227`
|
| 32 |
+
- Joint accuracy: `0.8327037147496438`
|
| 33 |
+
- Balanced score: `0.7994652870601522`
|
| 34 |
+
|
| 35 |
+
## Usage (Python, platform-independent)
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
import json
|
| 39 |
+
import numpy as np
|
| 40 |
+
from huggingface_hub import hf_hub_download
|
| 41 |
+
from tensorflow import keras
|
| 42 |
+
|
| 43 |
+
repo_id = "Nixion/next_activity_prediction_lifecycle_dual"
|
| 44 |
+
model_path = hf_hub_download(repo_id=repo_id, filename="model.keras")
|
| 45 |
+
metadata_path = hf_hub_download(repo_id=repo_id, filename="metadata.json")
|
| 46 |
+
|
| 47 |
+
with open(metadata_path, "r", encoding="utf-8") as f:
|
| 48 |
+
metadata = json.load(f)
|
| 49 |
+
|
| 50 |
+
model = keras.models.load_model(model_path)
|
| 51 |
+
sequence_length = int(metadata["sequence_length"])
|
| 52 |
+
activity_to_idx = metadata["activity_to_idx"]
|
| 53 |
+
lifecycle_to_idx = metadata["lifecycle_to_idx"]
|
| 54 |
+
|
| 55 |
+
def pad(xs, n):
|
| 56 |
+
return ([0] * (n - len(xs)) + xs)[-n:]
|
| 57 |
+
|
| 58 |
+
# Example history:
|
| 59 |
+
activity_hist = ["A_Create Application", "A_Submitted"]
|
| 60 |
+
lifecycle_hist = ["complete", "complete"]
|
| 61 |
+
|
| 62 |
+
X_act = np.array([pad([activity_to_idx.get(a, 0) for a in activity_hist], sequence_length)], dtype=np.int32)
|
| 63 |
+
X_life = np.array([pad([lifecycle_to_idx.get(l, 0) for l in lifecycle_hist], sequence_length)], dtype=np.int32)
|
| 64 |
+
|
| 65 |
+
pred_activity_probs, pred_lifecycle_probs = model.predict([X_act, X_life], verbose=0)
|
| 66 |
+
next_activity_idx = int(np.argmax(pred_activity_probs[0]))
|
| 67 |
+
next_lifecycle_idx = int(np.argmax(pred_lifecycle_probs[0]))
|
| 68 |
+
|
| 69 |
+
idx_to_activity = {int(k): v for k, v in metadata["idx_to_activity"].items()}
|
| 70 |
+
idx_to_lifecycle = {int(k): v for k, v in metadata["idx_to_lifecycle"].items()}
|
| 71 |
+
|
| 72 |
+
print("next_activity:", idx_to_activity.get(next_activity_idx))
|
| 73 |
+
print("next_lifecycle:", idx_to_lifecycle.get(next_lifecycle_idx))
|
| 74 |
+
```
|
best_model.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8fc0d73e4a141e87cd01718251b66963e055a00c5f460361b6b2703a5ea364ab
|
| 3 |
+
size 6822677
|
history.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activity_output_loss": [
|
| 3 |
+
0.46802908182144165
|
| 4 |
+
],
|
| 5 |
+
"activity_output_sparse_categorical_accuracy": [
|
| 6 |
+
0.8246452808380127
|
| 7 |
+
],
|
| 8 |
+
"lifecycle_output_loss": [
|
| 9 |
+
0.2494550198316574
|
| 10 |
+
],
|
| 11 |
+
"lifecycle_output_sparse_categorical_accuracy": [
|
| 12 |
+
0.8745477795600891
|
| 13 |
+
],
|
| 14 |
+
"loss": [
|
| 15 |
+
0.7174617648124695
|
| 16 |
+
],
|
| 17 |
+
"val_activity_output_loss": [
|
| 18 |
+
0.38813483715057373
|
| 19 |
+
],
|
| 20 |
+
"val_activity_output_sparse_categorical_accuracy": [
|
| 21 |
+
0.8443847894668579
|
| 22 |
+
],
|
| 23 |
+
"val_lifecycle_output_loss": [
|
| 24 |
+
0.2222922146320343
|
| 25 |
+
],
|
| 26 |
+
"val_lifecycle_output_sparse_categorical_accuracy": [
|
| 27 |
+
0.8857408165931702
|
| 28 |
+
],
|
| 29 |
+
"val_loss": [
|
| 30 |
+
0.610468327999115
|
| 31 |
+
],
|
| 32 |
+
"learning_rate": [
|
| 33 |
+
0.0010000000474974513
|
| 34 |
+
]
|
| 35 |
+
}
|
metadata.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "start_complete",
|
| 3 |
+
"methodology": "baseline",
|
| 4 |
+
"sequence_length": 50,
|
| 5 |
+
"activity_to_idx": {
|
| 6 |
+
"<PAD>": 0,
|
| 7 |
+
"A_Accepted": 1,
|
| 8 |
+
"A_Cancelled": 2,
|
| 9 |
+
"A_Complete": 3,
|
| 10 |
+
"A_Concept": 4,
|
| 11 |
+
"A_Create Application": 5,
|
| 12 |
+
"A_Denied": 6,
|
| 13 |
+
"A_Incomplete": 7,
|
| 14 |
+
"A_Pending": 8,
|
| 15 |
+
"A_Submitted": 9,
|
| 16 |
+
"A_Validating": 10,
|
| 17 |
+
"O_Accepted": 11,
|
| 18 |
+
"O_Cancelled": 12,
|
| 19 |
+
"O_Create Offer": 13,
|
| 20 |
+
"O_Created": 14,
|
| 21 |
+
"O_Refused": 15,
|
| 22 |
+
"O_Returned": 16,
|
| 23 |
+
"O_Sent (mail and online)": 17,
|
| 24 |
+
"O_Sent (online only)": 18,
|
| 25 |
+
"W_Assess potential fraud": 19,
|
| 26 |
+
"W_Call after offers": 20,
|
| 27 |
+
"W_Call incomplete files": 21,
|
| 28 |
+
"W_Complete application": 22,
|
| 29 |
+
"W_Handle leads": 23,
|
| 30 |
+
"W_Personal Loan collection": 24,
|
| 31 |
+
"W_Shortened completion ": 25,
|
| 32 |
+
"W_Validate application": 26,
|
| 33 |
+
"END_ACTIVITY": 27
|
| 34 |
+
},
|
| 35 |
+
"lifecycle_to_idx": {
|
| 36 |
+
"<PAD>": 0,
|
| 37 |
+
"complete": 1,
|
| 38 |
+
"start": 2,
|
| 39 |
+
"END_LIFECYCLE": 3
|
| 40 |
+
},
|
| 41 |
+
"idx_to_activity": {
|
| 42 |
+
"0": "<PAD>",
|
| 43 |
+
"1": "A_Accepted",
|
| 44 |
+
"2": "A_Cancelled",
|
| 45 |
+
"3": "A_Complete",
|
| 46 |
+
"4": "A_Concept",
|
| 47 |
+
"5": "A_Create Application",
|
| 48 |
+
"6": "A_Denied",
|
| 49 |
+
"7": "A_Incomplete",
|
| 50 |
+
"8": "A_Pending",
|
| 51 |
+
"9": "A_Submitted",
|
| 52 |
+
"10": "A_Validating",
|
| 53 |
+
"11": "O_Accepted",
|
| 54 |
+
"12": "O_Cancelled",
|
| 55 |
+
"13": "O_Create Offer",
|
| 56 |
+
"14": "O_Created",
|
| 57 |
+
"15": "O_Refused",
|
| 58 |
+
"16": "O_Returned",
|
| 59 |
+
"17": "O_Sent (mail and online)",
|
| 60 |
+
"18": "O_Sent (online only)",
|
| 61 |
+
"19": "W_Assess potential fraud",
|
| 62 |
+
"20": "W_Call after offers",
|
| 63 |
+
"21": "W_Call incomplete files",
|
| 64 |
+
"22": "W_Complete application",
|
| 65 |
+
"23": "W_Handle leads",
|
| 66 |
+
"24": "W_Personal Loan collection",
|
| 67 |
+
"25": "W_Shortened completion ",
|
| 68 |
+
"26": "W_Validate application",
|
| 69 |
+
"27": "END_ACTIVITY"
|
| 70 |
+
},
|
| 71 |
+
"idx_to_lifecycle": {
|
| 72 |
+
"0": "<PAD>",
|
| 73 |
+
"1": "complete",
|
| 74 |
+
"2": "start",
|
| 75 |
+
"3": "END_LIFECYCLE"
|
| 76 |
+
},
|
| 77 |
+
"end_activity_token": "END_ACTIVITY",
|
| 78 |
+
"end_lifecycle_token": "END_LIFECYCLE"
|
| 79 |
+
}
|
metrics.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "start_complete",
|
| 3 |
+
"methodology": "baseline",
|
| 4 |
+
"metrics": {
|
| 5 |
+
"activity_accuracy": 0.8443847963680949,
|
| 6 |
+
"activity_macro_f1": 0.6984303181387901,
|
| 7 |
+
"lifecycle_accuracy": 0.8857407959704411,
|
| 8 |
+
"lifecycle_macro_f1": 0.8672618282920227,
|
| 9 |
+
"joint_accuracy": 0.8327037147496438,
|
| 10 |
+
"balanced_score": 0.7994652870601522
|
| 11 |
+
},
|
| 12 |
+
"model_dir": "next_activity_prediction_lifecycle_dual\\models\\start_complete\\baseline"
|
| 13 |
+
}
|
model.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8fc0d73e4a141e87cd01718251b66963e055a00c5f460361b6b2703a5ea364ab
|
| 3 |
+
size 6822677
|