Python wrappers around the R 'dsld' package via rpy2
Project description
dsldPy — Python Interface to DSLD
Statistical and graphical tools for detecting and measuring discrimination and bias in datasets, Python interfaces available via rpy2. dsldPy wraps the R package dsld with a Python-friendly API using the same underlying R implementations.
Relevant links:
- Quarto Book: Paper - Important statistical principles and applications.
- Research Paper: Paper - Package implementation details.
Overview
DSLD addresses two main types of bias analysis:
-
Estimation analysis: quantify possible discrimination by estimating effects of a sensitive variable S on an outcome Y, while adjusting for confounders C.
-
Prediction analysis (fair ML): build predictive models that limit the influence of S and its proxies O, trading off fairness and utility.
dsldPy provides wrappers for all 24 R functions.
Prerequisites
- R installed and on PATH (R 4.x recommended)
- R package dsld installed (CRAN or GitHub)
- Python 3.8+
Install dsld in R:
install.packages("dsld")
## or latest development version
# install.packages("remotes")
remotes::install_github("matloff/dsld", force = TRUE)
Tip: Ensure rpy2 can find R. From a terminal: R RHOME should print your R home. If Python cannot find R, set R_HOME in your environment per rpy2’s documentation.
Installation
Install the Python package from this repository (subdirectory inst):
pip install dsldPy
This will install dsldPy and its Python dependencies (pandas, numpy, rpy2, etc.). The user still needs to manually download R and the dsld package, as noted above.
Quickstart
Please refer to the instructional jupyter notebooks provided under examples/ folder. These illustrate examples of all 24 dsldPy functions.
Jupyter notebooks are available in this repository:
inst/examples/graphical.ipynbinst/examples/tabular.ipynbinst/examples/machine_learning.ipynb
Available Wrappers
-
Analytical:
dsldPyLinear,dsldPyLogit,dsldPyML,dsldPyMatchedATE,dsldPyTakeALookAround,dsldPyConfounders,dsldPyCHunting,dsldPyOHunting -
Fair ML:
dsldPyFrrm,dsldPyFgrrm,dsldPyNclm,dsldPyZlm,dsldPyZlrm,dsldPyQeFairKNN,dsldPyQeFairRF,dsldPyQeFairRidgeLin,dsldPyQeFairRidgeLog, ,dsldPyFairUtils -
Graphical:
dsldPyFreqPCoord,dsldPyScatterPlot3D,dsldPyConditDisparity,dsldPyDensitybyS,dsldPyFrequencybyS,dsldPyIamb
Function names mirror the R package. Arguments use standard Python types (pandas.DataFrame, dict, bool, etc.) with the same call forms as the R functions.
Troubleshooting
- rpy2 cannot find R: confirm
R RHOMEworks; if not, add R to PATH or setR_HOME. See rpy2 docs for your OS. - dsld not installed in R: run
install.packages("dsld")in an R session.
Authors
- Norm Matloff
- Aditya Mittal
- Taha Abdullah
- Arjun Ashok
- Shubhada Martha
- Billy Ouattara
- Jonathan Tran
- Brandon Zarate
For issues, contact Aditya Mittal at mittalaa@uci.edu
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsldpy-0.0.2.tar.gz.
File metadata
- Download URL: dsldpy-0.0.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4e6b307abd910457e59a4113f20fbd834f42e8adf96dc0a8561a7c391dcee8d
|
|
| MD5 |
27d6635c31ef6cadca55c0e0aed77607
|
|
| BLAKE2b-256 |
322916af72b790ba6d0042ad9e9118d9c346740b7ac1f2f055241fbbc92f4786
|
File details
Details for the file dsldpy-0.0.2-py3-none-any.whl.
File metadata
- Download URL: dsldpy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a641efd7bc8bf07fde370c197541ff4935bc08ac0ed5888cbad95a5093fb3cc
|
|
| MD5 |
9fb70796844acbbf904b9dbc803d3a5e
|
|
| BLAKE2b-256 |
9c54986c03849f69dd222eb6893fe77d96da02edb9a6d8b1261379369c521c12
|