Fuzzy forest-style feature ranking using repeated random forests.
Project description
FuzzyForest
FuzzyForest is a small Python library that ranks features by stability using repeated random forests. It exposes:
FuzzyForestSelector: a scikit-learn compatible transformer that averages feature importances across many resampled forests.FuzzyForestRegressor: a regressor that selects features with the selector, then fits a final random forest on the reduced feature set.
Installation
pip install fuzzyforest
If you are developing locally, install in editable mode from the repo root:
pip install -e .
Quickstart
import numpy as np
from sklearn.datasets import fetch_california_housing
from fuzzyforest import FuzzyForestSelector, FuzzyForestRegressor
X, y = fetch_california_housing(return_X_y=True, as_frame=True)
# Rank and select the top 10 most stable features
selector = FuzzyForestSelector(top_k=10, n_resamples=30, random_state=42)
selector.fit(X, y)
print(selector.get_feature_ranking()) # ordered feature names
X_selected = selector.transform(X) # reduced feature matrix
# End-to-end regression with built-in selection
model = FuzzyForestRegressor(top_k=10, random_state=42)
model.fit(X, y)
print(model.score(X, y))
How it works
The selector builds n_resamples random forests, each on a bootstrap of the rows and a random subset of the columns. It averages the resulting feature importances, promoting features that are consistently useful across many draws. You can control:
sample_fractionandfeature_fractionto change how aggressive the perturbations are.top_kandmin_importanceto decide which features to keep.task("auto","classification","regression") to match the estimator.
Publishing
This project is configured for setuptools. Once you are ready to publish to GitHub or PyPI:
- Update
project.urls.Homepageinpyproject.tomlto the real repository URL. - Build the distribution:
python -m pip install build python -m build
- Upload to PyPI (optional):
python -m pip install twine twine upload dist/*
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fuzzyforest-0.1.0.tar.gz.
File metadata
- Download URL: fuzzyforest-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29a5511e6b0a02874357a7d5036d78c9a4d3d9ff945e6171443f91be2b243c3c
|
|
| MD5 |
fa1f5dacbbc4e67fa60f093befa341b3
|
|
| BLAKE2b-256 |
bf5bf7fb5d835dab06c8879d7441c327e9cf92b6b5d8274858a938f5f25bcbc6
|
File details
Details for the file fuzzyforest-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fuzzyforest-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46b8fa6702dabda1dc670db311de8105e5da77158d0529300802250045fbdda9
|
|
| MD5 |
899bbd28bd0a8a5a91ebcc1d266950ab
|
|
| BLAKE2b-256 |
3ae91866c6a2b378279869df5eb793e326e8c9d2aaee71fa0e56c34fa8692601
|