CoolFace
Modelpublic

Niansuh1/telemetry-kg-classifier

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
Model Card

Telemetry Knowledge-Graph Classifier

Zero-latency OS state classifier with knowledge-graph-based customizable inference and continuous online self-learning.

Classifies real-time user availability states from OS telemetry:

StateDescriptionAccuracy
๐ŸŽฏ Deep FocusSingle productive app, low switching, sustained work98.9%
๐ŸŽฎ GamingHigh CPU, fullscreen, game process, high network100%
๐Ÿ“น MeetingCommunication app active, calendar-matched, video I/O100%
๐ŸŸข AvailableFrequent switching, browser, mixed activities100%

Overall: 99.56% on continuous telemetry stream (5000 samples, unseen data)

Architecture

Dual-Model Ensemble

  • โ€”Tier 1 โ€” River AdaptiveRandomForest (10 HoeffdingTrees, depth=8): Instant online learner. Updates on every labeled sample in <1ms via learn_one(). Built-in ADWIN drift detection.
  • โ€”Tier 2 โ€” LightGBM (100 trees, depth=6): Accuracy anchor. Retrained every 30 min on a 2000-sample reservoir-sampled replay buffer.
  • โ€”Combiner: Adaptive weighted average. Weights shift based on which model has been more accurate recently.

Knowledge Graph (Customizable Inference)

A directed graph capturing relationships between processes, time blocks, and user states. Queried at inference time to produce Bayesian priors:

P_final(state) โˆ P_model(state|x)^0.7 ยท P_KG_prior(state|ctx)^0.3

Users can customize inference at runtime:

  • โ€”Add hard override rules (discord.exe โ†’ Meeting, priority=20)
  • โ€”Add processโ†’state edges with weights
  • โ€”Add time-based priors (9pm-12am non-work โ†’ Gaming)
  • โ€”Submit corrections that instantly update both models
  • โ€”Query what the system knows about any process or state

Feature Engineering (107 dimensions)

  • โ€”Welford online normalization (O(1) memory per feature)
  • โ€”Multi-scale EMAs (30s / 3min / 30min smoothing)
  • โ€”Rolling statistics (1min and 5min windows)
  • โ€”Feature hashing (16 buckets for process names โ€” no vocabulary explosion)
  • โ€”Cyclic temporal encoding (sin/cos for hour and day)
  • โ€”Rate-of-change features (first and second derivatives)

Usage

Quick Start

python
from huggingface_hub import hf_hub_download
import pickle, json

# Download artifacts
model_dir = hf_hub_download("Niansuh1/telemetry-kg-classifier", filename="arf_model.pkl",
                             local_dir="./model_artifacts")
# ... load all artifacts

Training

bash
pip install river lightgbm networkx psutil mmh3
python train.py --samples 30000 --output ./model_artifacts

Inference with Customization

bash
# Interactive CLI
python serve.py --mode cli

# JSON API
python serve.py --mode json

# Demo
python serve.py --mode demo

Knowledge Graph Customization Examples

python
# "Discord is always work meetings for me"
ensemble.kg.add_override_rule(
    rule_id="discord_meeting",
    condition={"process": "discord.exe"},
    target_state="Meeting",
    priority=20,
)

# "I game every evening"
ensemble.kg.add_rule(
    condition={"hour_range": [21, 24], "is_work_hours": False},
    target_state="Gaming",
    priority=5,
)

# Correct a wrong prediction (instant model update)
ensemble.learn(features, "Meeting", raw_telemetry, is_correction=True)

Resource Footprint

ComponentRAMCPU per cycle (3s)
Feature engineering1 MB0.5ms
River ARF model20 MB1ms
LightGBM model1 MB0.02ms
Knowledge Graph1 MB0.1ms
Total~25 MB~2ms (0.07% CPU)

Training Details

  • โ€”Data: 30,000 synthetic telemetry samples with Markov chain state transitions
  • โ€”Guaranteed class balance: 2000+ samples per state minimum
  • โ€”Online learning: ARF updates every sample, LightGBM retrains every 3000 samples
  • โ€”Concept drift: ADWIN detector on prediction error stream
  • โ€”Experience replay: 2000-sample reservoir-sampled buffer for LightGBM

References

  • โ€”River ML: Montiel et al., "River: machine learning for streaming data in Python", JMLR 2021
  • โ€”LightGBM: Ke et al., "LightGBM: A Highly Efficient Gradient Boosting Decision Tree", NeurIPS 2017
  • โ€”ADWIN: Bifet & Gavalda, "Learning from Time-Changing Data with Adaptive Windowing", SDM 2007
  • โ€”Feature Hashing: Weinberger et al., "Feature Hashing for Large Scale Multitask Learning", ICML 2009
  • โ€”Welford: B.P. Welford, "Note on a Method for Calculating Corrected Sums of Squares and Products", Technometrics 1962

<!-- ml-intern-provenance -->

Generated by ML Intern

This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.

  • โ€”Try ML Intern: https://smolagents-ml-intern.hf.space
  • โ€”Source code: https://github.com/huggingface/ml-intern