VFA - Variance Feature Analysis
A Python package for binary classification feature selection using variance-based analysis.
Overview
Variance Feature Analysis (VFA) implements a feature selection method based on the Class-Variance Ratio (CVR). It selects the most discriminative features for binary classification tasks by analyzing the ratio of between-class variance to total variance.
Installation
pip install vfa
Features
- Fast variance-based feature selection for binary classification
- Automatic feature ranking using Class-Variance Ratio (CVR)
- Weighted feature aggregation
- Compatible with scikit-learn workflows
- Lightweight with minimal dependencies (only NumPy)
Usage
from vfa import variance_feature_analysis
import numpy as np
# Example data
X = np.random.rand(100, 20) # 100 samples, 20 features
y = np.random.randint(0, 2, 100) # Binary labels
# Select top 5 features
X_selected, f_aggregated, selected_indices, scores = variance_feature_analysis(X, y, k=5)
print(f"Selected feature indices: {selected_indices}")
print(f"Feature scores: {scores[selected_indices]}")
Parameters
X(array-like): Training data features of shape (n_samples, n_features)y(array-like): Target labels of shape (n_samples,) - must be binaryk(int, default=8): Number of top features to selectepsilon(float, default=1e-12): Small constant to prevent division by zero
Returns
X_selected: Selected feature subsetf_aggregated: Weighted aggregation of selected featuresselected_idx: Indices of selected featuresscores: CVR scores for all features
How It Works
The algorithm:
- Computes within-class and between-class variance for each feature
- Calculates the Class-Variance Ratio (CVR) = B / (B + W)
- Selects the top-k features with highest CVR scores
- Returns selected features and their weighted aggregation
Requirements
- Python >=3.8
- NumPy >=1.20.0
Development
# Clone the repository
git clone https://github.com/nqmn/vfa.git
cd vfa
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Citation
If you use this package in your research, please cite:
@software{vfa2024,
title={VFA: Variance Feature Analysis},
author={Mohd Adil Mokti},
year={2026},
url={https://github.com/nqmn/vfa}
}
Metadata
Release files for vfa 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vfa-0.1.0.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vfa-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / vfa-0.1.0.tar.gz
| Download URL | vfa-0.1.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80268287669a4f15c3eda0ff8a90850c0bb97ee548d75f88713d237eb2759a36
|
|
BLAKE2b-256 checksum How to use checksums |
03815f034d0c01b12a4f53bee506d0a477d3ff305edd2b2d6881f0695d60433b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / vfa-0.1.0-py3-none-any.whl
| Download URL | vfa-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d121273862543b9a303b507e3e846ec83679bfe2683d73da5cdb326dd0c7f741
|
|
BLAKE2b-256 checksum How to use checksums |
6ed28e16ddeac1cf0825583f8cc0fcac2fb3b961765dee1561047998a9e6bdd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|