PyPunisher
A Python package that performs stepwise forward and backward feature selection
Install / Use
/learn @UBC-MDS/PyPunisherREADME
PyPunisher <img src="docs/logo/pypunisher_logo.png" align="right"/>
PyPunisher is a Python implementation of forward and backward feature selection. Feature selection, or stepwise regression, is a key step in the data science pipeline that reduces model complexity by selecting the most relevant features from the original dataset. This package implements two stepwise feature selection methods:
forward_selection(): starts with a null model and iteratively adds useful featuresbackward_elimination(): starts with a full model and iteratively removes the least useful feature at each step
These methods are greedy search algorithms that yield a nested subset of features. The size of the final feature subset depends on what you define as your "stopping criterion". The stopping criterion can be either a threshold that you define, or a pre-defined number of features to include in your model. For example, if you set your stopping criterion to be a threshold (min_change), then the feature selection process will stop when the AIC or BIC score no longer improves by that thresholded interval. Alternatively, if you want a specific number of features in your model, then the process will stop once it reaches n_features.
In order to measure model quality during the selection procedures, we have also implemented the Akaike and Bayesian Information Criterion, both of which punish complex models:
aic(): computes the Akaike Information Criterion (AIC)bic(): computes the Bayesian Information Criterion (BIC)
In general, having more parameters in your model increases prediction accuracy but is highly susceptible to overfitting. AIC and BIC add a penalty for the number of features in a model. This penalty term is larger in BIC than in AIC. A lower AIC or BIC score indicates a better fit for the data, relative to competing models.
Installation
pip3 install git+git://github.com/UBC-MDS/PyPunisher@master
Requires Python 3.6+.
Documentation
The documentation for PyPunisher can be viewed here.
How to run unit tests
From root directory, run all test files in terminal:
python -m pytest
You also have the option to run individual test files by referencing its path. For example:
python -m pytest tests/test_forward_selection.py
Contributions
Instructions and guidelines on how to contribute can be found here.
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
109.5kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
349.2kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
