본문으로 건너뛰기
Skillpedia
머신러닝51k · #3543

pymc

하는 일

이 도구는 PyMC 라이브러리를 사용해 베이즈 모델이라는 복잡한 통계 모델을 만들고 점검하도록 돕습니다. 데이터의 불확실성을 이해하고 예측을 하는 데 유용합니다.

사용하는 경우

  • ✓예측의 불확실성을 이해해야 할 때.
  • ✓사전 지식을 반영하는 통계 모델을 만들 때.
  • ✓여러 모델을 비교해 데이터에 가장 잘 맞는 모델을 찾을 때.

스킬 링크

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pymc/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pymc/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“과거 판매 데이터를 바탕으로 불확실성을 포함해 미래 판매를 예측하는 베이즈 모델을 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

통계 모델을 정의하면 PyMC가 고급 계산 방법을 사용해 모델의 매개변수를 추정하고 불확실성을 정량화합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

PyMC Bayesian Modeling

Version and scope

Targets PyMC 6.3.2, PyTensor 3.3.2, and ArviZ 1.3.0. These are local Python APIs, with no service endpoint, credentials, or remote inference required. The native tests use the PyMC NUTS sampler on small synthetic models. Optional nutpie/JAX samplers, SMC, and production-scale convergence are not validated by those tests. Record the complete resolved environment, backend, seeds, preprocessing, and data provenance for a scientific run.

Local macOS validation used PYTENSOR_FLAGS="cxx=" after the C linker failed with library 'd64' not found; this disables PyTensor C compilation for that process. The Python library workflows passed under that setting; it does not establish that the C backend works on this host.

ArviZ 1 splits into base/stats/plots packages, re-exported by import arviz as az. PyMC returns an xarray DataTree despite the legacy return_inferencedata option name. az.summary(..., round_to="none") returns numerical columns; the default formats for display. Use az.plot_ppc_dist, az.plot_dist, and az.plot_trace_dist; save their returned PlotCollection, not a separate pyplot figure. az.hdi(..., prob=.95) uses prob, with bounds along ci_bound.

Workflow

  1. Define the estimand and predictive unit: another measurement, a new patient or group, or a future time block. Preserve units, missingness assumptions and grouping. Fit any scaling only on training data; reject constant columns.
  2. Build a generative model with scientifically calibrated priors and named dimensions. Check likelihood support, finite initial log probability, design rank, confounding and symmetries before sampling.
  3. Run a prior predictive check and inspect domain-relevant summaries before fitting. A broad prior is not automatically noninformative or plausible.
  4. Fit several independent chains with explicit seeds. For reproducible backend selection use nuts_sampler="pymc"; the automatic choice can prefer installed nutpie. nuts={...} replaces deprecated nuts_sampler_kwargs.
  5. Inspect rank R-hat, bulk/tail ESS, estimand-specific MCSE, divergences, energy BFMI and sampler-specific tree depth. Fix geometry and initialization before simply increasing draws. A clean screen does not prove convergence.
  6. Generate posterior predictive replicates and inspect residual structure, tails, zeros, group effects and time dependence relevant to the question. In-sample agreement is not external validation or parameter identifiability.
  7. Compare prior sensitivity and parameter recovery on synthetic data. Weakly informed scales, correlated parameters, separated logistic data, or mixture label switching can survive good MCMC diagnostics. A proper prior may make a posterior finite without the likelihood identifying its parameters.
  8. Predict using the correct training transform and uncertainty levels. Keep predictions separate from in-sample posterior_predictive. Restore model data before recomputing training likelihoods.

See standard_workflow.md for a complete bounded API smoke example, workflows.md for missing values, scaling, predictive scoring and serialization, and model_patterns.md for model structures.

Runnable templates

From the skill directory, run the synthetic linear or hierarchical template:

uv run --isolated --with "pymc==6.3.2" --with "arviz==1.3.0" --with "pytensor==3.3.2" --with matplotlib --with pandas --with h5netcdf --with h5py python assets/linear_regression_template.py --draws 80 --tune 80 --chains 2 --output-dir linear_smoke
uv run --isolated --with "pymc==6.3.2" --with "arviz==1.3.0" --with "pytensor==3.3.2" --with matplotlib --with pandas --with h5netcdf --with h5py python assets/hierarchical_model_template.py --draws 80 --tune 80 --chains 2 --output-dir hierarchical_smoke

These short commands intentionally test execution and artifacts; they are not adequate evidence of converged scientific estimates. For a real analysis, inspect priors before fitting and budget chains/draws around diagnostics and required MCSE. The templates default to four chains and longer runs, but those counts are not acceptance criteria by themselves.

The hierarchical template predicts an unseen group by drawing group effects from every hyperposterior draw, sharing each group effect across that group's

…

자주 묻는 질문

베이즈 모델이란 무엇인가요?

확률을 사용해 불확실성을 나타내며, 데이터 정보와 사전 믿음(사전 분포)을 결합하는 통계 모델의 한 종류입니다.

MCMC란 무엇인가요?

베이즈 모델의 매개변수를 추정하기 위해 확률 분포에서 표본을 뽑는 계산 기법(마르코프 연쇄 몬테카를로)입니다.

‘사전 예측 검사(prior predictive checks)’란 무엇인가요?

모델을 데이터에 맞추기 전에, 초기 믿음(사전 분포)을 가진 모델이 합리적인 결과를 만드는지 확인하는 검사입니다.

상세 정보

작성자의 원본 설명

Builds and checks Bayesian models with PyMC, including hierarchical models, NUTS MCMC, variational inference, mutable-data predictions, posterior predictive checks, diagnostics, and PSIS-LOO model comparison. Use for probabilistic modeling and uncertainty inference in PyMC.

repo: K-Dense-AI/scientific-agent-skills

인기도

GitHub 스타
51k
순위
#3543
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬