Polars Buffers Skill
Guide for using Polars-based feature engineering buffers in LlamaFarm.
When to Load
Load this skill when the user:
- Asks about feature engineering
- Wants to compute rolling statistics
- Needs sliding window calculations
- Asks about lag features
- Wants to pre-process data for anomaly detection
- Needs time-series feature generation
API Overview
| Endpoint |
Method |
Description |
/v1/ml/buffers |
GET |
List all active buffers |
/v1/ml/buffers |
POST |
Create a new buffer |
/v1/ml/buffers/{name}/append |
POST |
Append data to a buffer |
/v1/ml/buffers/{name}/features |
GET |
Compute and retrieve features |
/v1/ml/buffers/{name}/data |
GET |
Read raw buffer contents |
/v1/ml/buffers/{name} |
DELETE |
Delete a buffer |
Feature Types
| Feature |
Description |
Example |
| Rolling Mean |
Average over a window |
5-min avg CPU usage |
| Rolling Std |
Standard deviation over window |
Volatility measure |
| Rolling Min |
Minimum in window |
Baseline detection |
| Rolling Max |
Maximum in window |
Peak detection |
| Lag |
Value from N periods ago |
Previous hour's value |
| Delta |
Change from N periods ago |
Rate of change |
Performance Characteristics
| Operation |
Typical Latency |
Notes |
| Append (single) |
< 1ms |
Lock-free for single writer |
| Append (batch 1K) |
< 5ms |
Batch preferred for throughput |
| Feature compute |
1-10ms |
Depends on window count |
| Buffer read |
1-5ms |
Depends on buffer size |
Use Cases
- Pre-process for anomaly detection -- Compute rolling stats, feed to streaming detector
- External ML pipeline -- Generate features, export for training
- Time series monitoring -- Track trends, detect regime changes
Quick Start
Create a buffer
curl -X POST http://localhost:14345/v1/ml/buffers \
-H "Content-Type: application/json" \
-d '{
"name": "server_metrics",
"max_size": 10000,
"columns": ["cpu", "memory", "disk_io", "network"],
"rolling_windows": [10, 50, 200],
"lag_periods": [1, 5, 10]
}'
Append data
curl -X POST http://localhost:14345/v1/ml/buffers/server_metrics/append \
-H "Content-Type: application/json" \
-d '{
"data": [
{"cpu": 45.2, "memory": 62.1, "disk_io": 120, "network": 500},
{"cpu": 47.8, "memory": 63.0, "disk_io": 115, "network": 520}
]
}'
Get computed features
curl http://localhost:14345/v1/ml/buffers/server_metrics/features
Progressive Disclosure
For detailed guidance:
buffer-management.md - Creating, appending, reading, memory management, deletion
feature-engineering.md - Rolling stats, window selection, lag design, ML integration
1---2name: polars-buffers3description: Polars-based feature engineering buffers. Create sliding windows, compute rolling statistics, and generate lag features for ML pipelines.4---56# Polars Buffers Skill78Guide for using Polars-based feature engineering buffers in LlamaFarm.910## When to Load1112Load this skill when the user:13- Asks about feature engineering14- Wants to compute rolling statistics15- Needs sliding window calculations16- Asks about lag features17- Wants to pre-process data for anomaly detection18- Needs time-series feature generation1920## API Overview2122| Endpoint | Method | Description |23|----------|--------|-------------|24| `/v1/ml/buffers` | GET | List all active buffers |25| `/v1/ml/buffers` | POST | Create a new buffer |26| `/v1/ml/buffers/{name}/append` | POST | Append data to a buffer |27| `/v1/ml/buffers/{name}/features` | GET | Compute and retrieve features |28| `/v1/ml/buffers/{name}/data` | GET | Read raw buffer contents |29| `/v1/ml/buffers/{name}` | DELETE | Delete a buffer |3031## Feature Types3233| Feature | Description | Example |34|---------|-------------|---------|35| Rolling Mean | Average over a window | 5-min avg CPU usage |36| Rolling Std | Standard deviation over window | Volatility measure |37| Rolling Min | Minimum in window | Baseline detection |38| Rolling Max | Maximum in window | Peak detection |39| Lag | Value from N periods ago | Previous hour's value |40| Delta | Change from N periods ago | Rate of change |4142## Performance Characteristics4344| Operation | Typical Latency | Notes |45|-----------|----------------|-------|46| Append (single) | < 1ms | Lock-free for single writer |47| Append (batch 1K) | < 5ms | Batch preferred for throughput |48| Feature compute | 1-10ms | Depends on window count |49| Buffer read | 1-5ms | Depends on buffer size |5051## Use Cases52531. **Pre-process for anomaly detection** -- Compute rolling stats, feed to streaming detector542. **External ML pipeline** -- Generate features, export for training553. **Time series monitoring** -- Track trends, detect regime changes5657## Quick Start5859### Create a buffer6061```bash62curl -X POST http://localhost:14345/v1/ml/buffers \63 -H "Content-Type: application/json" \64 -d '{65 "name": "server_metrics",66 "max_size": 10000,67 "columns": ["cpu", "memory", "disk_io", "network"],68 "rolling_windows": [10, 50, 200],69 "lag_periods": [1, 5, 10]70 }'71```7273### Append data7475```bash76curl -X POST http://localhost:14345/v1/ml/buffers/server_metrics/append \77 -H "Content-Type: application/json" \78 -d '{79 "data": [80 {"cpu": 45.2, "memory": 62.1, "disk_io": 120, "network": 500},81 {"cpu": 47.8, "memory": 63.0, "disk_io": 115, "network": 520}82 ]83 }'84```8586### Get computed features8788```bash89curl http://localhost:14345/v1/ml/buffers/server_metrics/features90```9192## Progressive Disclosure9394For detailed guidance:95- `buffer-management.md` - Creating, appending, reading, memory management, deletion96- `feature-engineering.md` - Rolling stats, window selection, lag design, ML integration