Cobra is a Python package to build predictive models using linear or logistic regression with a focus on performance and interpretation. It consists of several modules for data preprocessing, feature selection and model evaluation. The underlying methodology was developed at Python Predictions in the course of hundreds of business-related prediction challenges. It has been tweaked, tested and optimized over the years based on feedback from clients, our team, and academic researchers.
Main features
Prepare a given pandas DataFrame for predictive modelling:
partition into train/selection/validation sets
create bins from continuous variables
regroup categorical variables based on statistical significance
replace missing values
add columns where categories/bins are replaced with average of target values (linear regression) or with incidence rate (logistic regression)
Perform univariate feature selection based on RMSE (linear regression) or AUC (logistic regression)
Compute correlation matrix of predictors
Find the suitable variables using forward feature selection
Evaluate model performance and visualize the results
Getting started
These instructions will get you a copy of the project up and running on your local machine for usage, development and testing purposes.
Requirements
This package requires only the usual Python libraries for data science, being numpy, pandas, scipy, scikit-learn, matplotlib, seaborn, and tqdm. These packages, along with their versions are listed in requirements.txt and can be installed using pip:
pip install -r requirements.txt
Note: if you want to install Cobra with e.g. pip, you don’t have to install all these requirements as these are automatically installed with Cobra itself.
Installation
The easiest way to install Cobra is using pip:
pip install -U pythonpredictions-cobra
Documentation and extra material
A blog post on the overall methodology.
A research article by Geert Verstraeten (co-founder Python Predictions) discussing the preprocessing approach we use in Cobra.
HTML documentation of the individual modules.
Step-by-step tutorials for a logistic and a linear regression use case.
Check out the Data Science Leuven Meetup talk by one of the core developers (second presentation). His slides and related material are also available.
Contributing to Cobra
We’d love you to contribute to the development of Cobra! There are many ways in which you can contribute, the most common of which is to contribute to the source code or documentation of the project. However, there are many other ways you can contribute (report issues, improve code coverage by adding unit tests, …). We use GitHub issues to track all bugs and feature requests. Feel free to open an issue in case you found a bug or in case you wish to see a new feature added.
For more details, check out our wiki.
Metadata
Release files for pythonpredictions-cobra 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pythonpredictions-cobra-1.1.1.tar.gz | 39.0 kB | Without provenance | Details for pythonpredictions-cobra-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pythonpredictions_cobra-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for pythonpredictions_cobra-1.1.1-py3-none-any.whl |
Total release size: 84.6 kB
Release files / pythonpredictions-cobra-1.1.1.tar.gz
| Download URL | pythonpredictions-cobra-1.1.1.tar.gz |
|---|---|
| Size | 39.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a6fc446cdfc56e0ea880f62ae22471d7841fb89471ee442ef73a21834a0f8b3
|
|
BLAKE2b-256 checksum How to use checksums |
d28d083e442ef3e508563007f2c5b4d8654c8747e34edb988652f64a8a7fd5a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.5
|
Release files / pythonpredictions_cobra-1.1.1-py3-none-any.whl
| Download URL | pythonpredictions_cobra-1.1.1-py3-none-any.whl |
|---|---|
| Size | 45.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c36b2b80e22714eebcc9ade04e1d25f65548ca0654bb7f2ece14dfe40f1cdaed
|
|
BLAKE2b-256 checksum How to use checksums |
3c31f5fc5e9df6bfeafc8bfd36f820978edd917b5e17109b4cb256f06dbcff3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.5
|
Security for pythonpredictions-cobra 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.