{"id":27634,"library":"causallib","title":"CausalLib","description":"A Python package for flexible and modular causal inference modeling. Current version 0.10.0. Provides a scikit-learn compatible API for causal effect estimation, including propensity score matching, weighting, doubly robust estimation, and survival analysis. Released irregularly.","status":"active","version":"0.10.0","language":"python","source_language":"en","source_url":"https://github.com/BiomedSciAI/causallib","tags":["causal-inference","scikit-learn","propensity-score","inverse-probability-weighting","matching"],"install":[{"cmd":"pip install causallib","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for model wrappers and evaluation.","package":"scikit-learn","optional":false},{"reason":"Data handling and input validation.","package":"pandas","optional":false},{"reason":"Numerical computations.","package":"numpy","optional":false}],"imports":[{"note":"Top-level import works but not guaranteed; use submodule for clarity.","wrong":"from causallib import Weight","symbol":"Weight","correct":"from causallib.estimation import Weight"},{"note":"IPW is a subclass of Weight.","wrong":"from causallib import IPW","symbol":"IPW","correct":"from causallib.estimation import IPW"},{"note":"No causallib.match module.","wrong":"from causallib.match import Matching","symbol":"Matching","correct":"from causallib.estimation import Matching"},{"note":"","wrong":null,"symbol":"PropensityScoreMatching","correct":"from causallib.estimation import PropensityScoreMatching"}],"quickstart":{"code":"from causallib.datasets import load_ihdp\nfrom causallib.estimation import IPW\nfrom sklearn.linear_model import LogisticRegression\n\ndata = load_ihdp()\nX = data['X']\na = data['a']\ny = data['y']\n\nlearner = LogisticRegression(solver='lbfgs')\nipw = IPW(learner)\nipw.fit(X, a)\npotential_outcomes = ipw.estimate_population_outcome(X, a, y)\nprint(potential_outcomes)","lang":"python","description":"Fits Inverse Probability Weighting (IPW) to estimate potential outcomes on the IHDP dataset."},"warnings":[{"fix":"Convert inputs to pandas DataFrame/Series before fitting.","message":"Data must be provided as DataFrames (not array-like). Many methods internally expect pandas DataFrames for indexing and column alignment; passing numpy arrays may cause silent errors or attribute failures.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the new causal_metrics module and updated plot functions. See migration guide in the release notes.","message":"In version 0.9.0 the evaluation module was refactored; plot APIs changed. Old imports from causallib.evaluation no longer work.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Use the newer simulator API or external simulation libraries.","message":"The `causallib.simulation` module is being phased out. Networkx >=3 may break old simulation code.","severity":"deprecated","affected_versions":">=0.9.6"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Upgrade causallib to 0.9.7+ or use pandas to_numpy().","cause":"Older scikit-learn or causallib code uses deprecated `.as_matrix()` instead of `.values`.","error":"AttributeError: 'DataFrame' object has no attribute 'as_matrix'"},{"fix":"Use `from causallib.datasets import load_nhefs_survival`.","cause":"Deprecated dataset function removed; replaced by `load_nhefs_survival`.","error":"ImportError: cannot import name 'load_nhefs' from 'causallib.datasets'"},{"fix":"Convert X to DataFrame: `import pandas as pd; X = pd.DataFrame(X, columns=['col0','col1',...])`.","cause":"Passing X as numpy array without column names; causallib expects DataFrame with column names.","error":"KeyError: 'Columns not found' when calling .fit()"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}