harpertoken commited on
Commit
cdb35a5
·
verified ·
1 Parent(s): 294a7f2

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +55 -0
README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language: en
4
+ library_name: scikit-learn
5
+ tags:
6
+ - anomaly-detection
7
+ - isolation-forest
8
+ - time-series
9
+ - system-monitoring
10
+ - tabular
11
+ datasets:
12
+ - harpertoken/stat
13
+ metrics:
14
+ - precision
15
+ - recall
16
+ ---
17
+
18
+ # mark
19
+
20
+ An IsolationForest anomaly detector over the [`stat`](https://huggingface.co/datasets/harpertoken/stat) macOS system-telemetry dataset. It learns what normal machine behaviour looks like from per-second CPU, memory, disk and network counters, and flags samples that do not fit. CPU only, scikit-learn only, no PyTorch and no transformer anywhere in the path. The saved bundle is a StandardScaler plus a 200-tree forest, eight features, a few hundred kilobytes.
21
+
22
+ Training used the first 80 percent of the session in time order (4,951 rows) and held out the last 20 percent (1,238 rows). The disk and network columns in `stat` are since-boot counters, so they enter as per-interval differences, exactly as that card recommends. `cpu_temp` is null throughout and is dropped; per-core `cpu_usage` enters as its mean and max.
23
+
24
+ ## Usage
25
+
26
+ ```python
27
+ import numpy as np
28
+ from huggingface_hub import hf_hub_download
29
+ import joblib
30
+
31
+ bundle = joblib.load(hf_hub_download("harpertoken/mark", "model.joblib"))
32
+ X = np.array([[46.8, 96.0, 3410.2, 33.0, 6.1, 5.8, 0.4, 0.3]])
33
+ print(bundle["model"].predict(bundle["scaler"].transform(X)))
34
+ ```
35
+
36
+ The eight columns, in order, are `cpu_mean`, `cpu_max`, `memory_used_mb`, `battery_status`, `disk_read_delta`, `disk_write_delta`, `net_sent_delta` and `net_recv_delta`. Output is 1 for normal, -1 for flagged. The bundle is saved with joblib, which uses pickle internally; load it only from this repository.
37
+
38
+ ## Evaluation
39
+
40
+ Measured on the temporal holdout and on synthetic incidents built from holdout rows:
41
+
42
+ | Case | Flagged |
43
+ |---|---|
44
+ | Clean holdout (false alarms) | 0.027 |
45
+ | Stressed machine, CPU, memory and disk spiking together | 0.917 |
46
+ | Idle crash, CPU and memory dropping together | 0.372 |
47
+ | Network storm, sent and received spiking together | 0.245 |
48
+
49
+ The contamination parameter is 0.01, so about one percent of training rows score as anomalous by construction; the holdout false-alarm rate of 0.027 reflects the battery recharge region the holdout covers, which the training window never saw.
50
+
51
+ Single-feature extremes score poorly, and that is a property of the algorithm rather than a bug in this fit. IsolationForest separates points by random splits, and a point that is extreme in one of eight dimensions waits several splits for that dimension to be picked, which is the same depth normal points reach. Standardizing the features changes nothing for the same reason: the splits are uniform in range, and rescaling only reparametrizes the draw. Incidents that move several counters at once, the way a real stressed machine does, are the ones it catches.
52
+
53
+ ## Limitations
54
+
55
+ This models one machine over one 1-hour-44-minute session. It has not seen another host, another workload, or a longer timescale, and there is no reason to expect it to transfer. The synthetic incidents are illustrative, not a benchmark. The `stat` card's unit caveat applies here too: the disk and network deltas are raw counter advances whose physical unit was never confirmed, so thresholds learned on them are in those raw units.