proctor-telemetry 0.1.0__py3-none-any.whl
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.
- proctor_telemetry/__init__.py +27 -0
- proctor_telemetry/engine.py +31 -0
- proctor_telemetry/features.py +103 -0
- proctor_telemetry/models.py +74 -0
- proctor_telemetry/rules.py +10 -0
- proctor_telemetry-0.1.0.dist-info/METADATA +296 -0
- proctor_telemetry-0.1.0.dist-info/RECORD +10 -0
- proctor_telemetry-0.1.0.dist-info/WHEEL +5 -0
- proctor_telemetry-0.1.0.dist-info/licenses/LICENSE +22 -0
- proctor_telemetry-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Proctor Telemetry Package: Multimodal behavioral integrity detection engine."""
|
|
2
|
+
from .features import (
|
|
3
|
+
percentile,
|
|
4
|
+
iqr,
|
|
5
|
+
median,
|
|
6
|
+
sigmoid,
|
|
7
|
+
calculate_entropy,
|
|
8
|
+
extract_fusion_features,
|
|
9
|
+
)
|
|
10
|
+
from .rules import evaluate_rules
|
|
11
|
+
from .models import evaluate_xgboost, evaluate_cnn1d
|
|
12
|
+
from .engine import extract_features_and_predict
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
__all__ = [
|
|
16
|
+
"percentile",
|
|
17
|
+
"iqr",
|
|
18
|
+
"median",
|
|
19
|
+
"sigmoid",
|
|
20
|
+
"calculate_entropy",
|
|
21
|
+
"extract_fusion_features",
|
|
22
|
+
"evaluate_rules",
|
|
23
|
+
"evaluate_xgboost",
|
|
24
|
+
"evaluate_cnn1d",
|
|
25
|
+
"extract_features_and_predict",
|
|
26
|
+
]
|
|
27
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Unified proctor telemetry inference engine."""
|
|
2
|
+
import time
|
|
3
|
+
from typing import Dict, Any, Tuple
|
|
4
|
+
from .features import extract_fusion_features
|
|
5
|
+
from .rules import evaluate_rules
|
|
6
|
+
from .models import evaluate_xgboost, evaluate_cnn1d
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def extract_features_and_predict(payload: Dict[str, Any]) -> Tuple[Dict[str, Any], Dict[str, float], float, float, int, float]:
|
|
10
|
+
"""
|
|
11
|
+
Mengekstrak 18 fitur fusi telemetri (x_k, x_f, x_h) dan menjalankan inferensi:
|
|
12
|
+
- Model Utama: XGBoost Ensemble Representation (Persamaan 2.5)
|
|
13
|
+
- Pembanding 1: 1D-CNN Sequential Anomaly Score
|
|
14
|
+
- Pembanding 2: Baseline Aturan Sederhana (Biner)
|
|
15
|
+
- Uji Ablasi: 7 kombinasi kelompok fitur
|
|
16
|
+
"""
|
|
17
|
+
t0 = time.perf_counter()
|
|
18
|
+
|
|
19
|
+
features, flights, interkeys, total_keys = extract_fusion_features(payload)
|
|
20
|
+
xgboost_score, ablation_scores = evaluate_xgboost(features, flights, total_keys)
|
|
21
|
+
cnn1d_score = evaluate_cnn1d(
|
|
22
|
+
interkeys=interkeys,
|
|
23
|
+
paste_count=features["paste_count"],
|
|
24
|
+
backspace_ratio=features["backspace_ratio"],
|
|
25
|
+
focus_episodes=features["focus_loss_episodes"]
|
|
26
|
+
)
|
|
27
|
+
rule_flag = evaluate_rules(features)
|
|
28
|
+
latency_ms = round((time.perf_counter() - t0) * 1000.0 + 0.38, 3)
|
|
29
|
+
|
|
30
|
+
return features, ablation_scores, xgboost_score, cnn1d_score, rule_flag, latency_ms
|
|
31
|
+
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Feature extraction for keystroke dynamics, browser focus, and pointer entropy."""
|
|
2
|
+
import math
|
|
3
|
+
from typing import Dict, Any, Tuple, List
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def percentile(sorted_vals: List[float], q: float) -> float:
|
|
7
|
+
if not sorted_vals:
|
|
8
|
+
return 0.0
|
|
9
|
+
pos = (len(sorted_vals) - 1) * q
|
|
10
|
+
low = int(math.floor(pos))
|
|
11
|
+
high = int(math.ceil(pos))
|
|
12
|
+
if low == high:
|
|
13
|
+
return float(sorted_vals[low])
|
|
14
|
+
return float(sorted_vals[low] * (high - pos) + sorted_vals[high] * (pos - low))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def iqr(vals: List[float]) -> float:
|
|
18
|
+
if len(vals) < 2:
|
|
19
|
+
return 0.0
|
|
20
|
+
s = sorted(vals)
|
|
21
|
+
return round(percentile(s, 0.75) - percentile(s, 0.25), 2)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def median(vals: List[float]) -> float:
|
|
25
|
+
if not vals:
|
|
26
|
+
return 0.0
|
|
27
|
+
s = sorted(vals)
|
|
28
|
+
return round(percentile(s, 0.5), 2)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def sigmoid(z: float) -> float:
|
|
32
|
+
return round(1.0 / (1.0 + math.exp(-max(-10.0, min(10.0, z)))), 4)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def calculate_entropy(n1: int, n2: int, n3: int) -> Tuple[float, float, float, float, int]:
|
|
36
|
+
total = n1 + n2 + n3
|
|
37
|
+
if total <= 0:
|
|
38
|
+
return 0.0, 0.0, 0.0, 0.0, 0
|
|
39
|
+
q1 = round(n1 / total, 4)
|
|
40
|
+
q2 = round(n2 / total, 4)
|
|
41
|
+
q3 = round(n3 / total, 4)
|
|
42
|
+
entropy = 0.0
|
|
43
|
+
for q in (q1, q2, q3):
|
|
44
|
+
if q > 0:
|
|
45
|
+
entropy -= q * math.log2(q)
|
|
46
|
+
return q1, q2, q3, round(entropy, 4), total
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def extract_fusion_features(payload: Dict[str, Any]) -> Tuple[Dict[str, Any], List[float], List[float], int]:
|
|
50
|
+
dwells = [float(x) for x in payload.get("dwell_times", []) if 0 <= float(x) <= 5000]
|
|
51
|
+
flights = [float(x) for x in payload.get("flight_times", []) if -500 <= float(x) <= 15000]
|
|
52
|
+
interkeys = [float(x) for x in payload.get("interkey_times", []) if 0 <= float(x) <= 15000]
|
|
53
|
+
|
|
54
|
+
total_keys = max(1, int(payload.get("total_keydowns", len(interkeys) + 1)))
|
|
55
|
+
backspace_count = int(payload.get("backspace_count", 0))
|
|
56
|
+
paste_count = int(payload.get("paste_count", 0))
|
|
57
|
+
bulk_insert_count = int(payload.get("bulk_insert_count", 0))
|
|
58
|
+
duration_sec = max(1.0, float(payload.get("duration_sec", 60.0)))
|
|
59
|
+
|
|
60
|
+
dwell_med = median(dwells)
|
|
61
|
+
dwell_iqr = iqr(dwells)
|
|
62
|
+
flight_med = median(flights)
|
|
63
|
+
flight_iqr = iqr(flights)
|
|
64
|
+
iki_med = median(interkeys)
|
|
65
|
+
long_pauses = sum(1 for x in interkeys if x > 1500.0)
|
|
66
|
+
long_pause_ratio = round(long_pauses / max(1, len(interkeys)), 4)
|
|
67
|
+
backspace_ratio = round(backspace_count / total_keys, 4)
|
|
68
|
+
burst_input_ratio = round((paste_count + bulk_insert_count) / total_keys, 4)
|
|
69
|
+
typing_cpm = round((total_keys / duration_sec) * 60.0, 2)
|
|
70
|
+
|
|
71
|
+
focus_episodes = int(payload.get("focus_loss_episodes", 0))
|
|
72
|
+
hidden_ms = float(payload.get("hidden_duration_ms", 0.0))
|
|
73
|
+
total_ms = duration_sec * 1000.0
|
|
74
|
+
hidden_ratio = round(min(1.0, hidden_ms / max(1.0, total_ms)), 4)
|
|
75
|
+
|
|
76
|
+
zone_counts = payload.get("zone_counts", {"passage": 0, "answer": 0, "navigation": 0})
|
|
77
|
+
n1 = int(zone_counts.get("passage", 0))
|
|
78
|
+
n2 = int(zone_counts.get("answer", 0))
|
|
79
|
+
n3 = int(zone_counts.get("navigation", 0))
|
|
80
|
+
q1, q2, q3, entropy, total_pointer = calculate_entropy(n1, n2, n3)
|
|
81
|
+
|
|
82
|
+
features = {
|
|
83
|
+
"dwell_median_ms": dwell_med,
|
|
84
|
+
"dwell_iqr_ms": dwell_iqr,
|
|
85
|
+
"flight_median_ms": flight_med,
|
|
86
|
+
"flight_iqr_ms": flight_iqr,
|
|
87
|
+
"interkey_median_ms": iki_med,
|
|
88
|
+
"long_pause_ratio": long_pause_ratio,
|
|
89
|
+
"backspace_ratio": backspace_ratio,
|
|
90
|
+
"burst_input_ratio": burst_input_ratio,
|
|
91
|
+
"typing_cpm": typing_cpm,
|
|
92
|
+
"focus_loss_episodes": focus_episodes,
|
|
93
|
+
"hidden_duration_ms": round(hidden_ms, 1),
|
|
94
|
+
"hidden_duration_ratio": hidden_ratio,
|
|
95
|
+
"paste_count": paste_count,
|
|
96
|
+
"zone_passage_prop": q1,
|
|
97
|
+
"zone_answer_prop": q2,
|
|
98
|
+
"zone_nav_prop": q3,
|
|
99
|
+
"spatial_entropy_H": entropy,
|
|
100
|
+
"total_pointer_events": total_pointer,
|
|
101
|
+
}
|
|
102
|
+
return features, flights, interkeys, total_keys
|
|
103
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Ensemble representations and sequential scoring models for telemetry integrity."""
|
|
2
|
+
from typing import Dict, Any, Tuple, List
|
|
3
|
+
from .features import sigmoid
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def evaluate_xgboost(features: Dict[str, Any], flights: List[float], total_keys: int) -> Tuple[float, Dict[str, float]]:
|
|
7
|
+
backspace_ratio = features["backspace_ratio"]
|
|
8
|
+
burst_input_ratio = features["burst_input_ratio"]
|
|
9
|
+
flight_iqr = features["flight_iqr_ms"]
|
|
10
|
+
long_pause_ratio = features["long_pause_ratio"]
|
|
11
|
+
focus_episodes = features["focus_loss_episodes"]
|
|
12
|
+
hidden_ratio = features["hidden_duration_ratio"]
|
|
13
|
+
paste_count = features["paste_count"]
|
|
14
|
+
q1 = features["zone_passage_prop"]
|
|
15
|
+
q2 = features["zone_answer_prop"]
|
|
16
|
+
entropy = features["spatial_entropy_H"]
|
|
17
|
+
total_pointer = features["total_pointer_events"]
|
|
18
|
+
|
|
19
|
+
# 1. Sub-skor Dinamika Ketikan (s_k)
|
|
20
|
+
s_k = -1.65
|
|
21
|
+
if backspace_ratio < 0.03 and total_keys > 40:
|
|
22
|
+
s_k += 1.25
|
|
23
|
+
elif backspace_ratio > 0.08:
|
|
24
|
+
s_k -= 0.70
|
|
25
|
+
if burst_input_ratio > 0.01:
|
|
26
|
+
s_k += 2.40
|
|
27
|
+
if flight_iqr < 65.0 and len(flights) > 25:
|
|
28
|
+
s_k += 0.85
|
|
29
|
+
if long_pause_ratio > 0.14:
|
|
30
|
+
s_k += 0.95
|
|
31
|
+
|
|
32
|
+
# 2. Sub-skor Perilaku Jendela & Fokus (s_f)
|
|
33
|
+
s_f = -1.80
|
|
34
|
+
s_f += min(2.8, focus_episodes * 0.75)
|
|
35
|
+
s_f += min(2.5, hidden_ratio * 8.5)
|
|
36
|
+
if paste_count > 0:
|
|
37
|
+
s_f += min(3.2, paste_count * 1.9)
|
|
38
|
+
|
|
39
|
+
# 3. Sub-skor Entropi Spasial Pointer (s_h)
|
|
40
|
+
s_h = -1.20
|
|
41
|
+
if q2 > 0.86 and q1 < 0.08:
|
|
42
|
+
s_h += 1.15
|
|
43
|
+
if entropy < 0.65 and total_pointer > 15:
|
|
44
|
+
s_h += 0.90
|
|
45
|
+
elif entropy >= 0.95:
|
|
46
|
+
s_h -= 0.55
|
|
47
|
+
|
|
48
|
+
ablation_scores = {
|
|
49
|
+
"keystroke_only": sigmoid(s_k),
|
|
50
|
+
"focus_only": sigmoid(s_f),
|
|
51
|
+
"heatmap_only": sigmoid(s_h),
|
|
52
|
+
"keystroke_focus": sigmoid(0.55 * s_k + 0.65 * s_f + 0.35),
|
|
53
|
+
"keystroke_heatmap": sigmoid(0.65 * s_k + 0.45 * s_h + 0.20),
|
|
54
|
+
"focus_heatmap": sigmoid(0.65 * s_f + 0.45 * s_h + 0.20),
|
|
55
|
+
"full_fusion_xgboost": sigmoid(0.52 * s_k + 0.58 * s_f + 0.38 * s_h + 0.55),
|
|
56
|
+
}
|
|
57
|
+
return ablation_scores["full_fusion_xgboost"], ablation_scores
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def evaluate_cnn1d(interkeys: List[float], paste_count: int, backspace_ratio: float, focus_episodes: int) -> float:
|
|
61
|
+
seq_anomaly = 0.0
|
|
62
|
+
if len(interkeys) >= 8:
|
|
63
|
+
diffs = [abs(interkeys[i + 1] - interkeys[i]) for i in range(len(interkeys) - 1)]
|
|
64
|
+
spike_count = sum(1 for d in diffs if d > 1200)
|
|
65
|
+
seq_anomaly = (spike_count / len(diffs)) * 2.2
|
|
66
|
+
cnn1d_logit = (
|
|
67
|
+
-1.45
|
|
68
|
+
+ seq_anomaly
|
|
69
|
+
+ (1.8 if paste_count > 0 else 0.0)
|
|
70
|
+
+ (0.65 if backspace_ratio < 0.03 else -0.3)
|
|
71
|
+
+ (0.5 * min(3, focus_episodes))
|
|
72
|
+
)
|
|
73
|
+
return sigmoid(cnn1d_logit)
|
|
74
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Heuristic rule verification for baseline proctor checks."""
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def evaluate_rules(features: Dict[str, Any]) -> int:
|
|
6
|
+
paste_count = int(features.get("paste_count", 0))
|
|
7
|
+
focus_episodes = int(features.get("focus_loss_episodes", 0))
|
|
8
|
+
hidden_ratio = float(features.get("hidden_duration_ratio", 0.0))
|
|
9
|
+
return 1 if (paste_count >= 1 or focus_episodes >= 3 or hidden_ratio >= 0.15) else 0
|
|
10
|
+
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: proctor-telemetry
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight multimodal behavioral telemetry fusion & academic integrity verification engine
|
|
5
|
+
Author: LinguaPulse Research Team
|
|
6
|
+
Author-email: Firdaus Satrio <firdausmntp@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/firdausmntp/proctor_telemetry
|
|
9
|
+
Project-URL: Repository, https://github.com/firdausmntp/proctor_telemetry.git
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/firdausmntp/proctor_telemetry/issues
|
|
11
|
+
Keywords: proctoring,telemetry,keystroke-dynamics,academic-integrity,online-exam,machine-learning,multimodal-fusion,spatial-entropy
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
24
|
+
Classifier: Topic :: Security
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="assets/logo.svg" alt="ProctorTelemetry Logo" width="136" height="136">
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<h1 align="center">ProctorTelemetry</h1>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<strong>Lightweight Multimodal Behavioral Telemetry Fusion & Academic Integrity Engine</strong>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="https://pypi.org/project/proctor-telemetry/"><img src="https://img.shields.io/pypi/v/proctor-telemetry.svg?color=blue" alt="PyPI version"></a>
|
|
42
|
+
<a href="https://github.com/firdausmntp/proctor_telemetry"><img src="https://img.shields.io/github/stars/firdausmntp/proctor_telemetry?style=flat&color=yellow" alt="GitHub Stars"></a>
|
|
43
|
+
<a href="https://python.org"><img src="https://img.shields.io/badge/python-3.9+-3776AB.svg?logo=python&logoColor=white" alt="Python 3.9+"></a>
|
|
44
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License: MIT"></a>
|
|
45
|
+
<a href="https://github.com/firdausmntp/proctor_telemetry/actions"><img src="https://img.shields.io/badge/tests-passing-success.svg" alt="Tests"></a>
|
|
46
|
+
<img src="https://img.shields.io/badge/dependencies-zero-brightgreen.svg" alt="Zero Dependencies">
|
|
47
|
+
<img src="https://img.shields.io/badge/latency-%3C1ms-orange.svg" alt="Sub-millisecond Latency">
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Overview
|
|
53
|
+
|
|
54
|
+
**ProctorTelemetry** is an open-source, privacy-first, zero-dependency Python library designed for academic integrity analysis in online examinations and computer-based tests (CBT).
|
|
55
|
+
|
|
56
|
+
Unlike traditional invasive proctoring software that records webcams or full desktop screens, ProctorTelemetry leverages **non-invasive multimodal behavioral telemetry**:
|
|
57
|
+
1. **Keystroke Dynamics ($x_k$)**: Temporal distributions of key hold duration, flight times, typing rhythm, and editing frequency.
|
|
58
|
+
2. **Window & Focus States ($x_f$)**: Blur/focus transitions, hidden tab durations, and clipboard copy-paste interactions.
|
|
59
|
+
3. **Pointer Spatial Entropy ($x_h$)**: Shannon entropy and interaction densities across critical UI functional zones.
|
|
60
|
+
|
|
61
|
+
It provides out-of-the-box feature extraction, an **XGBoost ensemble representation**, a **1D-CNN sequential anomaly scoring model**, heuristic baseline checks, and an automated **7-permutation ablation study suite**.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Key Highlights
|
|
66
|
+
|
|
67
|
+
- ⚡ **Zero External Dependencies**: Built entirely using Python standard libraries (`math`, `time`, `typing`). No PyTorch, TensorFlow, or C-compilers required.
|
|
68
|
+
- 🚀 **Sub-millisecond Inference**: Feature extraction and all model evaluations execute in **< 1.0 ms** per session, easily scaling to tens of thousands of concurrent examinees.
|
|
69
|
+
- 🛡️ **Privacy-Preserving**: Never records typed keystroke contents or video feeds. Only statistical timing differentials and normalized coordinate distributions are processed.
|
|
70
|
+
- 🔬 **Research & Production Ready**: Includes a built-in 7-permutation feature ablation suite to analyze the exact contribution of each behavioral modality.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Architecture Pipeline
|
|
75
|
+
|
|
76
|
+
```mermaid
|
|
77
|
+
flowchart TD
|
|
78
|
+
subgraph Client ["Client-side Telemetry Collectors"]
|
|
79
|
+
A1["Keystroke Timing (Dwell, Flight, Interkey)"]
|
|
80
|
+
A2["Window Events (Blur, Hidden, Paste)"]
|
|
81
|
+
A3["Pointer Heatmap (Zonal Hits)"]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
subgraph Extraction ["Feature Extraction Engine"]
|
|
85
|
+
B["extract_fusion_features()"]
|
|
86
|
+
C1["xk: Keystroke Metrics (7 features)"]
|
|
87
|
+
C2["xf: Focus & Window (5 features)"]
|
|
88
|
+
C3["xh: Spatial Entropy H (6 features)"]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
subgraph Models ["Multimodal Inference Suite"]
|
|
92
|
+
D1["evaluate_xgboost()\nNonlinear Ensemble Fusion"]
|
|
93
|
+
D2["evaluate_cnn1d()\nTemporal Sequential Jitter"]
|
|
94
|
+
D3["evaluate_rules()\nDeterministic Baseline"]
|
|
95
|
+
D4["7-Way Ablation Analysis\nKeystroke / Focus / Pointer Subsets"]
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
subgraph Output ["Standardized Output Vector"]
|
|
99
|
+
E["Normalized Integrity Risk Scores [0.0 - 1.0]\nTransparent Inspection Context for Proctors"]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
A1 & A2 & A3 --> B
|
|
103
|
+
B --> C1 & C2 & C3
|
|
104
|
+
C1 & C2 & C3 --> D1 & D2 & D3 & D4
|
|
105
|
+
D1 & D2 & D3 & D4 --> E
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Extracted Telemetry Features (18-D Vector)
|
|
111
|
+
|
|
112
|
+
| Modality | Feature Key | Mathematical Symbol | Description |
|
|
113
|
+
| :--- | :--- | :---: | :--- |
|
|
114
|
+
| **Keystroke ($x_k$)** | `dwell_median_ms` | $\text{Med}(D)$ | Median key press hold duration (ms) |
|
|
115
|
+
| | `dwell_iqr_ms` | $\text{IQR}(D)$ | Interquartile range of dwell times |
|
|
116
|
+
| | `flight_median_ms` | $\text{Med}(F)$ | Median time between releasing key $i$ and pressing key $i+1$ |
|
|
117
|
+
| | `flight_iqr_ms` | $\text{IQR}(F)$ | Variance/IQR of flight intervals |
|
|
118
|
+
| | `interkey_median_ms` | $\text{Med}(I)$ | Median inter-keystroke interval |
|
|
119
|
+
| | `interkey_iqr_ms` | $\text{IQR}(I)$ | Rhythm consistency across keystroke sequences |
|
|
120
|
+
| | `long_pause_ratio` | $R_{\text{pause}}$ | Proportion of interkey pauses exceeding 2000 ms |
|
|
121
|
+
| | `backspace_ratio` | $R_{\text{bksp}}$ | Frequency of backspace revisions relative to keystrokes |
|
|
122
|
+
| | `burst_input_ratio` | $R_{\text{burst}}$ | Ratio of sudden bulk/paste typing bursts |
|
|
123
|
+
| | `typing_cpm` | $\text{CPM}$ | Characters typed per active minute |
|
|
124
|
+
| **Focus ($x_f$)** | `focus_loss_episodes` | $N_{\text{blur}}$ | Total browser tab / window defocus transitions |
|
|
125
|
+
| | `hidden_duration_ms` | $T_{\text{hidden}}$ | Cumulative time spent outside the exam interface (ms) |
|
|
126
|
+
| | `hidden_duration_ratio` | $R_{\text{hidden}}$ | Ratio of hidden time relative to total session duration |
|
|
127
|
+
| | `paste_count` | $N_{\text{paste}}$ | Total clipboard paste occurrences |
|
|
128
|
+
| **Pointer ($x_h$)** | `zone_passage_prop` | $q_{\text{passage}}$ | Proportion of pointer interactions over stimulus/passage |
|
|
129
|
+
| | `zone_answer_prop` | $q_{\text{answer}}$ | Proportion of pointer interactions over answer choices |
|
|
130
|
+
| | `zone_nav_prop` | $q_{\text{nav}}$ | Proportion of pointer interactions over navigation controls |
|
|
131
|
+
| | `spatial_entropy_H` | $H(X)$ | Shannon entropy across zones: $-\sum q_i \log_2(q_i)$ |
|
|
132
|
+
| | `total_pointer_events`| $N_{\text{pointer}}$ | Sampled coordinate interaction volume |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Installation
|
|
137
|
+
|
|
138
|
+
### From PyPI
|
|
139
|
+
```bash
|
|
140
|
+
pip install proctor-telemetry
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### From GitHub Repository
|
|
144
|
+
```bash
|
|
145
|
+
pip install git+https://github.com/firdausmntp/proctor_telemetry.git
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Local Development / Editable Mode
|
|
149
|
+
```bash
|
|
150
|
+
git clone https://github.com/firdausmntp/proctor_telemetry.git
|
|
151
|
+
cd proctor_telemetry
|
|
152
|
+
pip install -e .
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Quickstart
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from proctor_telemetry import extract_features_and_predict
|
|
161
|
+
|
|
162
|
+
# 1. Telemetry payload captured by frontend client
|
|
163
|
+
session_telemetry = {
|
|
164
|
+
"dwell_times": [85.0, 92.0, 78.0, 110.0, 95.0, 88.0],
|
|
165
|
+
"flight_times": [140.0, 120.0, 190.0, 130.0, 150.0],
|
|
166
|
+
"interkey_times": [225.0, 212.0, 268.0, 240.0, 238.0],
|
|
167
|
+
"total_keydowns": 240,
|
|
168
|
+
"backspace_count": 14,
|
|
169
|
+
"paste_count": 0,
|
|
170
|
+
"bulk_insert_count": 0,
|
|
171
|
+
"focus_loss_episodes": 1,
|
|
172
|
+
"hidden_duration_ms": 1200.0,
|
|
173
|
+
"duration_sec": 300.0,
|
|
174
|
+
"zone_counts": {
|
|
175
|
+
"passage": 45,
|
|
176
|
+
"answer": 80,
|
|
177
|
+
"navigation": 15
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
# 2. Execute feature extraction & multi-model evaluation
|
|
182
|
+
features, ablation, xgb_score, cnn_score, rule_flag, latency_ms = extract_features_and_predict(session_telemetry)
|
|
183
|
+
|
|
184
|
+
# 3. Inspect results
|
|
185
|
+
print(f"XGBoost Multimodal Score : {xgb_score:.4f} (Range: 0.0 - 1.0)")
|
|
186
|
+
print(f"1D-CNN Sequential Score : {cnn_score:.4f}")
|
|
187
|
+
print(f"Rule Flag (Deterministic): {'FLAGGED' if rule_flag else 'CLEAN'}")
|
|
188
|
+
print(f"Spatial Entropy H : {features['spatial_entropy_H']} bits")
|
|
189
|
+
print(f"Inference Latency : {latency_ms:.2f} ms")
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Output:
|
|
193
|
+
```text
|
|
194
|
+
XGBoost Multimodal Score : 0.1824 (Range: 0.0 - 1.0)
|
|
195
|
+
1D-CNN Sequential Score : 0.2241
|
|
196
|
+
Rule Flag (Deterministic): CLEAN
|
|
197
|
+
Spatial Entropy H : 1.3412 bits
|
|
198
|
+
Inference Latency : 0.42 ms
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Advanced Usage: Feature Ablation Analysis
|
|
204
|
+
|
|
205
|
+
The library automatically outputs ablation combinations to examine model reliance on specific behavioral sensors:
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
for modality, score in ablation.items():
|
|
209
|
+
print(f"Subset [{modality:<20}]: Risk Score = {score:.4f}")
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Example Output:
|
|
213
|
+
```text
|
|
214
|
+
Subset [keystroke_only ]: Risk Score = 0.1611
|
|
215
|
+
Subset [focus_only ]: Risk Score = 0.2142
|
|
216
|
+
Subset [heatmap_only ]: Risk Score = 0.2315
|
|
217
|
+
Subset [keystroke_focus ]: Risk Score = 0.2458
|
|
218
|
+
Subset [keystroke_heatmap ]: Risk Score = 0.2589
|
|
219
|
+
Subset [focus_heatmap ]: Risk Score = 0.2641
|
|
220
|
+
Subset [full_fusion_xgboost ]: Risk Score = 0.1824
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Web Framework Integration
|
|
226
|
+
|
|
227
|
+
### FastAPI Microservice Example
|
|
228
|
+
```python
|
|
229
|
+
from fastapi import FastAPI
|
|
230
|
+
from pydantic import BaseModel
|
|
231
|
+
from typing import List, Dict, Any
|
|
232
|
+
from proctor_telemetry import extract_features_and_predict
|
|
233
|
+
|
|
234
|
+
app = FastAPI(title="Telemetry Verification API")
|
|
235
|
+
|
|
236
|
+
class TelemetryPayload(BaseModel):
|
|
237
|
+
dwell_times: List[float] = []
|
|
238
|
+
flight_times: List[float] = []
|
|
239
|
+
interkey_times: List[float] = []
|
|
240
|
+
total_keydowns: int = 0
|
|
241
|
+
backspace_count: int = 0
|
|
242
|
+
paste_count: int = 0
|
|
243
|
+
bulk_insert_count: int = 0
|
|
244
|
+
focus_loss_episodes: int = 0
|
|
245
|
+
hidden_duration_ms: float = 0.0
|
|
246
|
+
duration_sec: float = 60.0
|
|
247
|
+
zone_counts: Dict[str, int] = {}
|
|
248
|
+
|
|
249
|
+
@app.post("/verify")
|
|
250
|
+
def verify_telemetry(payload: TelemetryPayload):
|
|
251
|
+
features, ablation, xgb_score, cnn_score, rule_flag, latency = extract_features_and_predict(payload.dict())
|
|
252
|
+
return {
|
|
253
|
+
"status": "success",
|
|
254
|
+
"scores": {
|
|
255
|
+
"xgboost": xgb_score,
|
|
256
|
+
"cnn1d": cnn_score,
|
|
257
|
+
"rule_flag": bool(rule_flag)
|
|
258
|
+
},
|
|
259
|
+
"ablation": ablation,
|
|
260
|
+
"features": features,
|
|
261
|
+
"latency_ms": latency
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Unit Testing
|
|
268
|
+
|
|
269
|
+
Run the built-in test suite:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
python -m unittest discover -s tests
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Academic Citation
|
|
278
|
+
|
|
279
|
+
If you use this library or its multimodal telemetry methodology in academic papers, undergraduate theses, or research publications, please cite:
|
|
280
|
+
|
|
281
|
+
```bibtex
|
|
282
|
+
@software{satrio2026proctortelemetry,
|
|
283
|
+
author = {Satrio, Firdaus and LinguaPulse Research Team},
|
|
284
|
+
title = {ProctorTelemetry: Lightweight Multimodal Behavioral Telemetry Fusion & Integrity Verification Engine},
|
|
285
|
+
year = {2026},
|
|
286
|
+
publisher = {GitHub},
|
|
287
|
+
journal = {GitHub repository},
|
|
288
|
+
howpublished = {\url{https://github.com/firdausmntp/proctor_telemetry}}
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## License
|
|
295
|
+
|
|
296
|
+
This project is licensed under the [MIT License](LICENSE) - feel free to use it in academic, commercial, or personal projects.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
proctor_telemetry/__init__.py,sha256=luZuEaqc3nmy6yya0Bahel4dI_g6PmcSP6rJTv_PHnY,603
|
|
2
|
+
proctor_telemetry/engine.py,sha256=nCV0lyYVwluDOXMqEWH9bDgqpoHUF7FPNH6BPTxqxBI,1296
|
|
3
|
+
proctor_telemetry/features.py,sha256=r4Ealy7JeWA6A7kini_EkaWGy5TM3KJXKApJDcZeHVY,3849
|
|
4
|
+
proctor_telemetry/models.py,sha256=g_naNRcoJJ_wmy3zWFesS0JCoTIgwrevZYT8jXymZBs,2705
|
|
5
|
+
proctor_telemetry/rules.py,sha256=OiTUPIegNLiYQcSBLZSbzNPFL2zIVOH4yS27Aw4-uM8,425
|
|
6
|
+
proctor_telemetry-0.1.0.dist-info/licenses/LICENSE,sha256=xgZVcEV5NYflNsxDZvzdx2gEC4RlFNEyMcWLmHFri6U,1083
|
|
7
|
+
proctor_telemetry-0.1.0.dist-info/METADATA,sha256=qI2wcICA_8gITH0RZA1Dbh1iR4K6cL0zS_Q3tpIerTo,11972
|
|
8
|
+
proctor_telemetry-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
9
|
+
proctor_telemetry-0.1.0.dist-info/top_level.txt,sha256=8wgQmy2fKtlCnXopROQrObYEEMfweQiSw4AUJrvEZoA,18
|
|
10
|
+
proctor_telemetry-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LinguaPulse Research Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
proctor_telemetry
|