Coarse approximation linear function with cross validation
Project description
Calf, CalfCV
A binomial classifier that implements the Coarse Approximation Linear Function (CALF).
Contact
Rolf Carlson hrolfrc@gmail.com
Install
Use pip to install calfcv.
pip install calfcv
Introduction
This is a python implementation of the Coarse Approximation Linear Function (CALF). The implementation is based on the greedy forward selection algorithm described in the paper referenced below.
Two classes are provided: Calf, and CalfCV. Calf provides classification and prediction for two classes, the binomial case. Multinomial classification with more than two cases is not implemented. Calf provides a transform method that can be used for feature selection and dimensionality reduction of data sets. Calf requires that the feature matrix be scaled to have zero mean and unit variance. CalfCV provides the same functionality as Calf, but CalfCV includes built in data scaling and cross-validation. Choose Calf over CalfCV if you are optimizing hyperparameters over a grid using cross-validation.
Both Calf and CalfCV are designed for use with scikit-learn pipelines and composite estimators.
Example
from calfcv import CalfCV
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
Make a classification problem
seed = 42
X, y = make_classification(
n_samples=30,
n_features=5,
n_informative=2,
n_redundant=2,
n_classes=2,
random_state=seed
)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=seed)
Train the classifier
cls = CalfCV().fit(X_train, y_train)
Get the score on unseen data
cls.score(X_test, y_test)
0.875
References
Jeffries, C.D., Ford, J.R., Tilson, J.L. et al. A greedy regression algorithm with coarse weights offers novel advantages. Sci Rep 12, 5440 (2022). https://doi.org/10.1038/s41598-022-09415-2
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
File details
Details for the file calfcv-0.3.17.tar.gz
.
File metadata
- Download URL: calfcv-0.3.17.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1681c9ec0723eae81209d20e5112dd13268a54017cf0c0aec226221a29e5eaf4 |
|
MD5 | 1cf8685cd6607aaf9eac3d6c2d9f5d6c |
|
BLAKE2b-256 | bcef5aa3df6ac9b62e7cca4fa5d868fce61691e4805f3ad7a061dd597c8df403 |
File details
Details for the file calfcv-0.3.17-py3-none-any.whl
.
File metadata
- Download URL: calfcv-0.3.17-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb015fa35d9c172836813142244eb1651edf92c178df6d94f095ad3889eea51e |
|
MD5 | 3d4ae246d6736e2705fae802ef6a5b0e |
|
BLAKE2b-256 | 3c512756b1abb8d461f1b22a42c4c577417cb12794f45f73c21c3b90c9bd0692 |