estimate-online-covariance
Estimate a covariance / correlation / precision matrix incrementally with precise. Use when data arrives as a stream and you want the matrix updated per observation, or when you want an online (partial_fit) drop-in for sklearn.covariance, which is batch-only.
适合你,如果数据是流式到达,需要实时更新协方差矩阵
/ 下载安装
/ 通过 npx 安装 校验哈希
npx oh-my-skill add microprediction/precise/estimate-online-covariance/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- microprediction/precise/estimate-online-covariance/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify microprediction/precise/estimate-online-covariance安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
333GitHub stars
~409上下文体积 · 单文件
索引托管
怎么用
商店整理自技能原文 · 版本 d89c883 · 表述以原文为准它做什么
能实时处理流数据,每收到一个新样本就增量更新协方差、相关系数和精度矩阵,同时输出运行均值和已观察样本数。
什么时候触发
当你描述数据流式到达、要求每个观测更新矩阵,或需要在线替代 sklearn.covariance 时触发。
装好后可以这样说
每次传入一个观测值,输出最新协方差。
使用 EwaCovariance,r参数可调衰减速度。
技能原文 SKILL.md
Estimate online covariance with precise
precise provides sklearn-style estimators with a single partial_fit contract. Pure numpy.
pip install precise
The pattern
import numpy as np
from precise import EwaCovariance # exponentially weighted; recency-biased
est = EwaCovariance(r=0.05) # r in (0,1]; larger = faster forgetting
for y in stream: # y is a 1-D array (one observation)
est.partial_fit(y)
est.covariance_ # (d, d) ndarray, symmetric and PSD by construction
est.correlation_ # unit-diagonal correlation
est.precision_ # inverse covariance (when well-conditioned)
est.location_ # running mean
est.n_samples_ # observations seen
fit(X) is the batch drop-in (X is 2-D, rows = observations); it resets then replays rows, so it matches sklearn.covariance's call shape.
Choosing the class
all_estimators() lists every estimator; estimator_from_name("LedoitWolfCovariance") looks one up. Sensible defaults by situation:
- general / recency-weighted:
EwaCovariance(r=...) - many variables relative to samples (p/n large) or ill-conditioned:
LedoitWolfCovariance,OASCovariance,ShrunkCovariance,FactorCovariance - heavy tails / outliers:
HuberCovariance,TylerCovariance - regime changes:
AdaptiveEwaCovariance,DCCCovariance - you don't know: use the choose-covariance-estimator skill (
suggest(X)).
Notes
- All estimators are truly online — constant work per observation, no growing buffers.
- State is a JSON-able dict:
est.get_state()/est.set_state(s)for mid-stream checkpointing. covariance_is always symmetric PSD; don't hand-symmetrize or clip it yourself.- Named series with a changing universe? Use the keyed-dynamic-universe skill instead.
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →
评论
登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。
…