Overview
This package implements Distance Weighted Discrimination (DWD). DWD For details see (Marron et al 2007, Wang and Zou 2018). Originally implemented in Python by Iain Carmichael. Currently maintained by Kitware, Inc.
The package currently implements:
-
Original DWD formulation solved with Second Order Cone Programming (SOCP) and solved using cvxpy.
-
Genralized DWD (gDWD) and kernel gDWD solved with the Majorization-Minimization algorithm presented in Wang and Zou, 2018.
Marron, James Stephen, Michael J. Todd, and Jeongyoun Ahn. "Distance-weighted discrimination." Journal of the American Statistical Association 102, no. 480 (2007): 1267-1271.
Wang, Boxiang, and Hui Zou. "Another look at distance‐weighted discrimination." Journal of the Royal Statistical Society: Series B (Statistical Methodology) 80, no. 1 (2018): 177-198.
Installation
The DWD package can be installed via pip or github. This package is currently only tested in python 3.6.
$ pip install dwd
The conic solver socp_dwd.DWD depends on cvxpy, which is not available on all platforms. See the cvxpy installation instructions. If cvxpy dependencies are met, then use pip install dwd[socp].
Flit is used for packaging, and all package metadata is stored in pyproject.toml. To install this project locally or for development, use flit install or build a pip-installable wheel with flit build.
Example
from sklearn.datasets import make_blobs
from dwd.socp_dwd import DWD
# sample sythetic training data
X, y = make_blobs(
n_samples=200,
n_features=2,
centers=[[0, 0],
[2, 2]],
)
# fit DWD classifier
dwd = DWD(C='auto').fit(X, y)
# compute training accuracy
dwd.score(X, y) # 0.94
from sklearn.datasets import make_circles
from dwd.gen_kern_dwd import KernGDWD
# sample some non-linear, toy data
X, y = make_circles(n_samples=200, noise=0.2, factor=0.5, random_state=1)
# fit kernel DWD wit gaussian kernel
kdwd = KernGDWD(
lambd=.1, kernel='rbf',
kernel_kws={'gamma': 1},
).fit(X, y)
# compute training accuracy
kdwd.score(X, y) # 0.915
For more example code see these example notebooks (including the code to generate the above figures). If the notebooks aren't loading on github you can copy/paste the notebook url into https://nbviewer.jupyter.org/.
Help and Support
Additional documentation, examples and code revisions are coming soon.
Documentation
The source code is located on github: https://github.com/slicersalt/dwd
Testing
Testing is done using nose.
Contributing
We welcome contributions to make this a stronger package: data examples, bug fixes, spelling errors, new features, etc.
Metadata
Release files for dwd 1.0.5
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 |
|---|---|---|---|---|
| dwd-1.0.5.tar.gz | 214.3 kB | Without provenance | Details for dwd-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dwd-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for dwd-1.0.5-py3-none-any.whl |
Total release size: 237.0 kB
Release files / dwd-1.0.5.tar.gz
| Download URL | dwd-1.0.5.tar.gz |
|---|---|
| Size | 214.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b93790801dfc5f7002a74a1894bfc2229de3ccbe4a027bf800a99fbfcbc67aa
|
|
BLAKE2b-256 checksum How to use checksums |
4985274e5785a9f02f66195ce2fc025e925ec09685e10aa8ea90d5b51852336e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.25.1
|
Release files / dwd-1.0.5-py3-none-any.whl
| Download URL | dwd-1.0.5-py3-none-any.whl |
|---|---|
| Size | 22.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcd48b77c390ff882a1750ef263971943c44b05071332d9d5d59b87cd1816ad8
|
|
BLAKE2b-256 checksum How to use checksums |
81e92484e01d71982cc8ea7e7c69224e4b6ca872b562b2246642fd1537fe0756
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.25.1
|
Security for dwd 1.0.5
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.