Skip to main content

Shared data-mining library for the causal research suite — profile, associate, KPI, morphemes, insights, auto feature engineering

Project description

DataMine Lib

Shared data-mining library for the causal research suite — one facade that profiles columns, mines associations, extracts KPIs (tabular + optional vision), exports morpheme catalogs, runs auto feature engineering (propose → build → test), and emits markdown/JSON reports.

Package: datamine · PyPI-style name: datamine-lib · version 0.5.0

from datamine import DataMiner, MineReport, AutoFeatureEngine, auto_features, library_help

miner = DataMiner.from_csv("x.csv", prefer_autocausal=False)  # also from_df, from_sqlalchemy, from_public_join
report = miner.profile().associate().kpi().morphemes().insights().report()
# or: report = miner.run()

print(report.to_markdown())
ac = miner.to_autocausal()   # optional, if AutoCausalLib installed
civ = miner.to_causaliv()    # CausalIV-shaped KPI catalog dict

# Auto feature engineering (miners → SLM guide → coding agent → test)
miner.auto_features(
    target="conversion",
    research_problem="What drives conversion?",
    use_slm=False,
    use_causal_adapter=True,  # optional causal-heuristic seeds (≠ identification)
    coding_llm="builders",    # offline; or "auto" (cloud → local → builders)
    coding_harness="sys",     # offline; or "auto" (openclaw → hermes → sys)
)
print(miner.report().auto_features["kept"])

# or convenience → AutoFeatureReport
from datamine import auto_features
fe = auto_features(
    df, target="conversion", research_problem="...", use_slm=False,
    use_causal_adapter=True, coding_llm="builders", coding_harness="sys",
    prefer_autocausal=False,
)
print(fe.to_markdown())

print(library_help(module="features"))

Exploratory FE / association testing ≠ causal identification. Significance vs a target is associational evidence only. Causal heuristics (when enabled) seed proposals — they are not causal identification.

See docs/auto_features.md for the full pipeline and call path.

Install

cd research/DataMineLib
pip install -e ".[dev]"

# optional extras
pip install -e ".[vision]"   # opencv
pip install -e ".[sql]"      # sqlalchemy
pip install -e ".[fe]"       # sklearn, scipy, statsmodels, nltk, gensim, spaCy, transformers
pip install -e ../AutoCausalLib   # preferred tabular backend
pip install -e ../CausalIVSuite   # preferred KPI backend

Pipeline overview

Classic mine
  profile → associate → kpi → morphemes → insights → MineReport

Auto features
  miners (+ optional causal heuristics / morpheme+vision seeds)
       → optional SLM guide (default off)
       → coding harness (openclaw|hermes|sys) + coding LLM
       → significance / keep-reject (+ optional refine-on-failure)
       → adaptive multi-round on augmented work frame → AutoFeatureReport

CLI

python -m datamine --help
python -m datamine help --all
python -m datamine help --module features
python -m datamine help --api
python -m datamine help --cli

python -m datamine mine --csv path/to/data.csv
python -m datamine mine --csv path/to/data.csv --json -o report.json
python -m datamine mine --csv data.csv --with-features --target conversion
python -m datamine guides
python -m datamine adapters

# Auto features: propose → build → significance-test (offline-safe flags)
python -m datamine features --csv path/to/data.csv --target conversion \
  --problem "What drives conversion?" --causal-heuristics \
  --coding-llm builders --coding-harness sys --show-backends \
  --feature-frame-out feats.csv --max-refine 1
python -m datamine features --parquet data.parquet --target y
python -m datamine pipeline --csv data.csv --target y --coding-llm builders
python -m datamine features --csv data.csv --target y --json -o fe.json

Examples

Runnable offline demos under examples/:

Script Pipeline
examples/01_classic_mine.py Fluent classic mine
examples/02_auto_features.py Full auto-features (builders + sys)
examples/03_causal_heuristics.py + use_causal_adapter=True
examples/04_coding_harness.py coding_llm="auto" / coding_harness="auto"
examples/run_cli_examples.ps1 CLI walkthrough (Windows)
python examples/01_classic_mine.py
python examples/02_auto_features.py
python examples/04_coding_harness.py --force-builders

Auto feature engineering

Pipeline: mine associations / association rules / KPIs → advanced statistical miners (+ optional causal heuristics adapter) seed proposals → optional SLM re-rank → coding agent LLM (OpenAI / Claude / Grok / local / builders) → whitelist builders → significance + distribution tests → iterate.

Coding LLM (coding_llm="auto"): cloud if API key present → best on-device → deterministic builders-only. Keys via env (OPENAI_API_KEY, ANTHROPIC_API_KEY, XAI_API_KEY / GROK_API_KEY, DATAMINE_LLM_*) — never hardcode.

Coding harness (coding_harness="auto"): OpenClaw → Hermes → built-in sys. Soft-degrades when externals are missing. See docs/auto_features.md and docs/coding_harness.md.

Advanced miners (soft deps; sources on FeatureProposal):

source what it does
mi Mutual information / dependence ranks (sklearn)
anova ANOVA / Kruskal for categorical↔numeric
cramers_v Chi-square / Cramér's V for categorical–categorical
partial_corr Partial / residualized associations
dist_transform Skew/kurtosis → log / rank / bin
outlier Extreme-value indicator flags
stratified_lift Level lift vs base rate
vif Multicollinearity notes → ratio proposals
causal_heuristic / autocausal_adapter Optional causal-role heuristics (treatment/confounder/…) — seeds only, ≠ identification

Also: correlation pairs, association rules (equals_value for target-linked rules), research-problem term overlap, NLP term features. Enable causal seeds with use_causal_adapter=True or --causal-heuristics.

Environment variables

Variable Role
OPENAI_API_KEY OpenAI coding LLM
ANTHROPIC_API_KEY Claude coding LLM
XAI_API_KEY / GROK_API_KEY Grok coding LLM
DATAMINE_LLM_API_KEY + DATAMINE_LLM_BASE_URL OpenAI-compatible endpoint
DATAMINE_LLM_MODEL Model id for compatible endpoint
DATAMINE_CODING_LLM Default provider (auto / builders / …)
DATAMINE_CODING_HARNESS Default harness (auto / sys / …)
DATAMINE_OPENCLAW_BIN / DATAMINE_HERMES_BIN External harness CLI paths
DATAMINE_OPENCLAW_CMD / DATAMINE_HERMES_CMD Optional command templates
DATAMINE_LOCAL_LLM_MODEL Local on-device model id

Full table: docs/coding_harness.md · docs/auto_features.md.

Guides

datamine.guides detects installed suite packages and recommends which miner/backend to use (AutoCausal, CausalIV AutoKPI, VisionKPI, NextFrameSeq image_mine, MorphemeStudio, EquityIV, FactorIV, CausalSearch).

Product adapters

Thin optional adapters live in each product as <pkg>.datamine_adapter. Soft-import datamine — products keep working without it. See docs/ADAPTERS.md.

Docs

Help

python -m datamine --help
python -m datamine help --all|--module features|--api|--cli
from datamine import library_help
print(library_help(all=True))
print(library_help(api=True))

Catalog covers: DataMiner, auto_features, AutoFeatureEngine, CodingAgent, harness, causal heuristics.

Tests

pip install -e ".[dev]"
pytest -q

CausalBridge

Registered as datamine in the CausalBridge catalog. Workflow:

python -m causalbridge workflow datamine_all --dry-run

GitHub

https://github.com/ehallford11714/datamine-lib

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datamine_lib-0.5.0.tar.gz (108.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datamine_lib-0.5.0-py3-none-any.whl (109.4 kB view details)

Uploaded Python 3

File details

Details for the file datamine_lib-0.5.0.tar.gz.

File metadata

  • Download URL: datamine_lib-0.5.0.tar.gz
  • Upload date:
  • Size: 108.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for datamine_lib-0.5.0.tar.gz
Algorithm Hash digest
SHA256 9b2a8e8c8c7a588c7ad0e2804a956a2247539573be84d6699cb981497f156b3b
MD5 9dc9eb94d01c48dc0d566279bb6cca45
BLAKE2b-256 bb08cb6139a6aefa7fb9b280f903176a4e0516f5740528446e1e7f5cc86f3c8d

See more details on using hashes here.

File details

Details for the file datamine_lib-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: datamine_lib-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 109.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for datamine_lib-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc72c8880b5e4ca7d2aab9e9b2c0d7443f989375d8cc0bed577d82a7f61df6b4
MD5 9560c3f0ef6c9423195e817b3f0e67c8
BLAKE2b-256 2a9158a63811dcf806ed51bc9c1d053b7760bc5c262a38792182f46e86526954

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page