leakage-audit
Skill3 starsChanged yesterdayApache-2.0View on GitHub
特徴量に、答えの言い換え、単位の識別子、予測する時点より後の情報が紛れ込んでいないかを調べる。特徴量と分割表ができた後、モデルの点数を信じる前に使う。点数が良すぎるときにも使う。
2 other projects use a version of this.
Adopted by
Most recently taken up by
- thanatchon36/skillstheir own version, first seen Oct 15, 2026
- gmanch94/claude-code-aidlc-templatetheir own version, first seen Jul 11, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- gmanch94/claude-code-aidlc-template★ 2same name
- thanatchon36/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository56 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/AGENTS.mdAGENTS.md
- analysis-reportingSkill
- analysis-unit-designSkill
- analysis-visualizeSkill
- anomaly-detectionSkill
- areal-interpolationSkill
- causal-designSkill
- causal-estimationSkill
- clustering-analysisSkill
- cross-validation-designSkill
- data-quality-auditSkill
- dataset-discoverySkill
- data-variable-semanticsSkill
- dimensionality-reductionSkill
- eda-and-baselineSkill
- experiment-designSkill
- frontend-designSkill
- grid-risk-mappingSkill
- image-segmentationSkill
- land-cover-costSkill
- location-privacySkill
- model-explanationSkill
- natural-japaneseSkill
- noise-ceiling-analysisSkill
- observation-bias-auditSkill
- poi-insightsSkill
- point-pattern-analysisSkill
- raster-cost-distanceSkill
- raster-data-integrationSkill
- research-paper-writingSkill
- research-question-generationSkill
- robustness-analysisSkill
- sar-change-detectionSkill
- spatial-accessibility-analysisSkill
- spatial-autocorrelationSkill
- spatial-data-integrationSkill
- spatial-data-modelingSkill
- spatial-feature-engineeringSkill
- spatial-gnnSkill
- spatial-interpolationSkill
- spatial-network-analysisSkill
- spatial-optimizationSkill
- spatial-process-modelingSkill
- spatial-sampling-designSkill
- spatial-weights-designSkill
- spatiotemporal-modelingSkill
- stop-describing-uiSkill
- street-imagery-inspectionSkill
- terrain-hydrologySkill
- time-series-forecastingSkill
- trajectory-predictionSkill
- travel-time-reliabilitySkill
- uncertainty-estimationSkill
- web-design-guidelinesSkill
- yomiyasuSkill
The file
Files
leakage-audit
リークは、点数が良く見えるという形でしか現れない。良い点数が出たら、まず漏れを疑う。
このスキルは、できあがった特徴量を監査する。分け方によるリーク (同じ単位の別の行を覚える) は、評価の分け方を変えて点数の差を見ることで確かめる。分割表は、どの行を学習に、どの行を試験に使うかを書いた Parquet (1 行が repeat、fold、id、role。role は train か test) で、--folds-file に渡す。
「旗が立つ」は、そのスクリプトが警告の印を付けること。
手順
- 特徴量ごとに、出どころと、いつ分かる値かを書いた表を作る。目的変数と同じ出どころ、同じ調査、同じ計算から作った特徴量は印を付ける。予測する時点より後にしか分からない値は除く。 因果の問いでは、基準の時点は処置の決まった時点で、それより後に決まる変数を調整に入れるのは、効果の一部を消すか経路を開く別の誤りになる。
scripts/audit_features.pyを、本番の使い道に合った分割表で動かす。- 甘い分割表 (行を無作為に) でも動かし、1 つずつの特徴量の点数を比べる。
- 旗の立った特徴量を、下の表で読み、除くか、残す理由を書く。識別子、コード、URL の列は、値だけでなく、あるかないかも調べる (次の節)。規則で除く特徴量も、除く前に、1 つの特徴量の点数を測って書く。除いた理由が、測った点数で裏付けられる。
- 除いたら、モデルの点数を出し直す。
監査の 4 つの検査
scripts/audit_features.py は、同じ分割表、同じ採点 (同じ場所の compare_models.py) で次を出す。
| 検査 | 何をするか | 旗が立ったら |
| 1 つの特徴量 | 特徴量 1 つだけのブースティングの点数 (回帰は R2、分類は AUC)。--flag-score 以上で旗 | 目的変数の言い換えか、同じ源から作った値か |
| 単位の識別子 | --group の各グループの中で一定で、グループごとに違う値を取る特徴量に旗 | 単位を覚えるのに使える。単位で分けない評価では点数を水増しする |
| 目的変数の並べ替え | 答え (目的変数) を行の間でランダムに入れ替えてから、全ての特徴量で学習した点数。入れ替えた答えは予測できないはずなので、点数は 0 付近になるはず | 0 を明らかに超えたら、特徴量の外 (前処理を全行で学習した、行の重複) から漏れている |
| 重複 | 試験側の行のうち、特徴量の値が学習側のどれかの行と完全に同じものの数 | 同じ観測が二重に入っているか、特徴量が粗すぎて行を区別できない |
uvx --with duckdb --with scikit-learn python scripts/audit_features.py \
tmp/table.parquet ID TARGET F1 F2 F3 --task regression --group UNIT \
--folds-file tmp/folds_unit.parquetテストは uvx --with duckdb --with scikit-learn --with pytest pytest scripts/test_audit_features.py。4 つの検査それぞれを無効にすると落ちることを確かめてある。
分割表を変えると位置のリークが見える
国 × 年の平均寿命 (WDI、2010〜2022 年、212 か国、2,723 行) に、わざと 2 つの怪しい特徴量を足して監査した (2026-10-10)。男性の平均寿命 (SP.DYN.LE00.MA.IN) と、国の位置 (Natural Earth の LABEL_X、LABEL_Y)。
| 特徴量 1 つの R2 | 行を無作為に | 国で分ける |
| 男性の平均寿命 | 0.979 | 0.976 |
| 緯度 | 0.827 | -0.323 |
| 経度 | 0.807 | -0.723 |
| 1 人あたり GDP (対数) | 0.681 | 0.643 |
- 男性の平均寿命は、どちらの分け方でも 1 つで当たる。目的変数の言い換えで、分け方では防げない。
- 緯度と経度は、行を無作為に分けると 1 つで 0.8 を超え、国で分けると負になる。国ごとに一定の値なので、国の識別子として働き、同じ国の別の年を当てていた。単位の識別子の検査でも旗が立つ (212 か国で 212 通り)。
- 1 人あたり GDP は、分け方を変えても点数がほとんど変わらない。単位の識別子ではなく、目的変数との関係で効いている。
- 目的変数を並べ替えた点数は -0.034 と -0.018 で、仕組みの側からの漏れは見えなかった。
位置そのものが説明になる問い (気候、地形) もある。位置を特徴量に残すなら、単位で分けた評価で効くかを確かめる。
値があるかないかが、答えの言い換えになる
識別子、コード、URL、備考の列は、値の中身ではなく、入っているかどうかが目的変数を言い換えていることがある。audit_features.py の「1 つの特徴量」は値を見るので、文字列の列は対象から外れやすい。次で確かめる。
select scheduled_service, count(*) as n, count(iata_code) as with_code
from 'hf://datasets/yuiseki/ourairports-2026-08/parquet/airports.parquet' group by all;OurAirports の飛行場 86,002 件 (2026-10-13)。定期便のあるものが 4,333 件で、そのうち 4,132 件 (95%) が IATA コードを持つ。定期便のないもの 81,669 件で、コードを持つのは 4,925 件 (6%) だけ。コードがあるかないかだけで、定期便の有無をかなり言い当てる。コードが、目的変数の結果として付く (就航に合わせて割り当てる) ものなら、予測する時点では使えない。そうなのかは、ここでは確かめていないので、除く理由には「あるかないかの点数が高いこと」と、「確かめていないこと」を書く。
- 列を「識別子だから使わない」と除くだけでは、気づいたことにならない。あるかないかの表 (上のような集計) か、あるかないかの 1 つの特徴量の点数を書いて、除く理由にする。
- 使い道で、予測する時点にまだ分からない値 (採番、割り当てが、目的変数の結果として行われるもの) は、除く。
入れてよい特徴量かは、使い道で決める
点数が高く、リークでもない特徴量でも、使い道によっては入れてはいけない。「定期便の情報が無い飛行場について、定期便の有無を推定する」なら、特徴量は、情報の無い飛行場でも分かる値でなければならない。
- OurAirports の
typeは、large_airportが、定義の上で、定期便のある飛行場を指す (公式の凡例)。種類は定期便の有無を言い換える列になりうる。以前のエージェントの実行 (2026-10-13) では、type1 つの AUC が 0.916 だった。 typeが、予測する時点で分かる、独立に付けられた値かを、使い道から書く。独立でない (定期便があるから large とされる) なら、除く。入れるなら、入れた場合と除いた場合の両方の点数を並べ、入れた理由を書く。「点数が上がった」は理由にならない。- 点数で見つけるのでなく、列の定義 (凡例、データのカード) を読んで見つける。特徴量ごとに、定義の 1 行を、出どころの表に書く。
書き出すもの
- 特徴量ごとの出どころと、いつ分かる値か
- 使った分割表と、比べた甘い分割表
- 4 つの検査の結果と、旗の立った特徴量の扱い (除いた、残した理由)
- 規則で除いた特徴量 (識別子、コードなど) と、除く前に測った点数、または、あるかないかの集計
- 除いた後のモデルの点数
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

