{"id":46704938,"url":"https://github.com/abimael10/anomaly-grid","last_synced_at":"2026-03-09T08:01:47.782Z","repository":{"id":306744385,"uuid":"1026879309","full_name":"Abimael10/anomaly-grid","owner":"Abimael10","description":"Sequential pattern analysis through variable-order Markov chains. Built for detecting deviations in finite-alphabet sequences.","archived":false,"fork":false,"pushed_at":"2025-12-11T20:51:58.000Z","size":451,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-12T19:30:39.756Z","etag":null,"topics":["algorithm","algorithms","algorithms-and-data-structures","anomaly-detection","anomaly-detection-models","information-theory","markov-chain","network-analysis","probability","rust","rust-crate","rust-library","shannon-entropy","systemverilog"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Abimael10.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-26T20:11:22.000Z","updated_at":"2025-12-11T20:51:54.000Z","dependencies_parsed_at":"2025-07-27T11:41:13.974Z","dependency_job_id":"701bb13c-50cd-4f28-87f9-4ca31c964645","html_url":"https://github.com/Abimael10/anomaly-grid","commit_stats":null,"previous_names":["abimael10/anomaly-grid"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/Abimael10/anomaly-grid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abimael10%2Fanomaly-grid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abimael10%2Fanomaly-grid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abimael10%2Fanomaly-grid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abimael10%2Fanomaly-grid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Abimael10","download_url":"https://codeload.github.com/Abimael10/anomaly-grid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abimael10%2Fanomaly-grid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30287446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","algorithms","algorithms-and-data-structures","anomaly-detection","anomaly-detection-models","information-theory","markov-chain","network-analysis","probability","rust","rust-crate","rust-library","shannon-entropy","systemverilog"],"created_at":"2026-03-09T08:01:05.421Z","updated_at":"2026-03-09T08:01:47.767Z","avatar_url":"https://github.com/Abimael10.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anomaly Grid\n\n     █████╗ ███╗   ██╗ ██████╗ ███╗   ███╗ █████╗ ██╗  ██╗   ██╗\n    ██╔══██╗████╗  ██║██╔═══██╗████╗ ████║██╔══██╗██║  ╚██╗ ██╔╝\n    ███████║██╔██╗ ██║██║   ██║██╔████╔██║███████║██║   ╚████╔╝ \n    ██╔══██║██║╚██╗██║██║   ██║██║╚██╔╝██║██╔══██║██║    ╚██╔╝  \n    ██║  ██║██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║  ██║███████╗██║   \n    ╚═╝  ╚═╝╚═╝  ╚═══╝ ╚═════╝ ╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝╚═╝   \n    [ANOMALY-GRID v0.4.3] - SEQUENCE ANOMALY DETECTION ENGINE\n\n[![Crates.io](https://img.shields.io/crates/v/anomaly-grid.svg)](https://crates.io/crates/anomaly-grid)\n[![Downloads](https://img.shields.io/crates/d/anomaly-grid.svg)](https://crates.io/crates/anomaly-grid)\n[![Documentation](https://docs.rs/anomaly-grid/badge.svg)](https://docs.rs/anomaly-grid)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Rust library implementing variable-order Markov chains for sequence anomaly detection in finite alphabets.\n\n## Quick Start\n\n```toml\n[dependencies]\nanomaly-grid = \"0.4.3\"\n```\n\n```rust\nuse anomaly_grid::*;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Create detector (order-3)\n    let mut detector = AnomalyDetector::new(3)?;\n\n    // Train on a richer pattern set: repeating ABC blocks plus a few benign variants\n    let mut normal_sequence = Vec::new();\n    for _ in 0..30 {\n        normal_sequence.extend([\"A\", \"B\", \"C\", \"A\", \"B\", \"C\", \"A\", \"B\", \"C\"].iter().cloned());\n    }\n    normal_sequence.extend([\"A\", \"B\", \"A\", \"C\", \"A\", \"B\", \"C\"].iter().cloned());\n    normal_sequence.extend([\"A\", \"C\", \"B\", \"A\", \"B\", \"C\"].iter().cloned());\n    let normal_sequence = normal_sequence\n        .into_iter()\n        .map(|s| s.to_string())\n        .collect::\u003cVec\u003c_\u003e\u003e();\n    detector.train(\u0026normal_sequence)?;\n\n    // Detect deviations\n    let test_sequence = [\"A\", \"B\", \"C\", \"X\", \"Y\", \"C\", \"A\", \"B\", \"C\"]\n        .iter()\n        .map(|s| s.to_string())\n        .collect::\u003cVec\u003c_\u003e\u003e();\n    let anomalies = detector.detect_anomalies(\u0026test_sequence, 0.2)?;\n\n    for anomaly in anomalies {\n        println!(\n            \"Anomaly window {:?}, Strength: {:.3}\",\n            anomaly.sequence, anomaly.anomaly_strength\n        );\n    }\n\n    Ok(())\n}\n```\n\nExpected output with the above data:\n- Two anomaly windows flagged: `[\"B\",\"C\",\"X\",\"Y\"]` (strength ~0.27) and `[\"C\",\"X\",\"Y\",\"C\"]` (strength ~0.39).\n- No other windows reported; the rest of the test sequence matches the trained ABC pattern.\n\n## What This Library Does\n\n- Variable-order Markov modeling for finite alphabets (order 1..max_order with fallback).\n- On-the-fly scoring: likelihood + information score, combined into an anomaly strength.\n- Memory-conscious storage: string interning, trie-based contexts, SmallVec for small counts.\n- Batch processing: detect anomalies across many sequences in parallel (Rayon).\n- Tunable config: smoothing, weights, memory limit, and optimization helpers for pruning.\n\n## Configuration\n\n```rust\nlet config = AnomalyGridConfig::default()\n    .with_max_order(4)?                    // Higher order = more memory, better accuracy\n    .with_smoothing_alpha(0.5)?            // Lower = more sensitive to training data\n    .with_weights(0.8, 0.2)?               // Likelihood vs information weight\n    .with_memory_limit(Some(100 * 1024 * 1024))?; // 100MB memory limit\n\nlet detector = AnomalyDetector::with_config(config)?;\n```\n\n## Use Cases (with context)\n\nMarkov chains **are not state of the art** for anomaly detection. Modern systems favor deep sequence, probabilistic, and graph-based models. This library remains useful when you need:\n- Discrete, low-dimensional states with short contexts.\n- Predictable workflows where interpretability matters.\n- Ultra-low-latency or resource-constrained inference.\n\n### Practical fits\n- **Network/Protocol flows**: Finite state machines, handshake/order violations.\n- **Small structured workflows**: Ops runbooks, CLI/session macros, simple ETL steps.\n- **Device/state telemetry**: Low-cardinality IoT states, embedded controllers.\n\n### Not a fit without heavy preprocessing\n- High-dimensional logs/sensors or complex user behavior with long-range dependencies.\n- Large alphabets or non-stationary patterns.\n- Continuous/unstructured data (images, audio, raw text) without discretization.\n\n### Current state-of-the-art alternatives\n- **Deep sequence models**: LSTM/GRU, Transformers (TFT, Anomaly Transformer, TS foundation models), autoencoders/VAEs.\n- **Probabilistic deep models**: Normalizing flows, diffusion, energy-based models.\n- **Graph/representation learning**: GNNs, dynamic graph embeddings, contrastive methods.\n- **Classical statistical baselines**: HMMs (strong Markovian baseline), GMMs/Bayesian changepoint, ARIMA/VAR/Kalman for continuous signals.\n- **TS foundation models (2023–2025)**: TimeGPT, Chronos, MOIRAI, DeepTime.\n\n## Testing\n\n```bash\n# Run all tests\ncargo test\n\n# Run specific test suites\ncargo test unit_           # Unit tests\ncargo test integration_    # Integration tests\ncargo test domain_         # Domain tests\ncargo test performance_    # Performance tests (run with --release for perf thresholds)\n\n# Run examples\ncargo run --example communication_protocol_analysis\ncargo run --example network_protocol_analysis\ncargo run --example protein_folding_sequences\n```\n\n## Documentation\n\n- **[Complete Documentation](docs/)** - Comprehensive guides and API reference\n- **[API Reference](https://docs.rs/anomaly-grid)** - Online API documentation\n- **[Examples](examples/)**\n- **[Changelog](CHANGELOG.md)** - Version history and changes\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabimael10%2Fanomaly-grid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabimael10%2Fanomaly-grid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabimael10%2Fanomaly-grid/lists"}