Swarmauri Measurement Mutual Information
Mutual-information measurement plugin for Swarmauri pipelines. Computes the average mutual information (in bits) between every feature column and a target column, letting you rank signal strength before training models.
Features
- Wraps
sklearn.feature_selection.mutual_info_classifbehind the standardMeasurementBaseAPI. - Supports Pandas DataFrame inputs; automatically excludes the target column from the feature set.
- Returns the average mutual information across all features (in bits) for quick screening.
Prerequisites
- Python 3.10 or newer.
scikit-learnandpandasinstalled (pulled in as dependencies of this package).- Clean, pre-processed categorical data (encode non-numeric columns before calling) since
mutual_info_classifexpects numerical inputs.
Installation
# pip
pip install swarmauri_measurement_mutualinformation
# poetry
poetry add swarmauri_measurement_mutualinformation
# uv (pyproject-based projects)
uv add swarmauri_measurement_mutualinformation
Quickstart
import pandas as pd
from swarmauri_measurement_mutualinformation import MutualInformationMeasurement
# Example dataset
frame = pd.DataFrame(
{
"feature_a": [0, 1, 1, 0, 1, 0],
"feature_b": [5.1, 5.0, 4.9, 5.2, 5.1, 5.0],
"target": [0, 1, 1, 0, 1, 0],
}
)
mi = MutualInformationMeasurement()
avg_mi = mi.calculate(frame, target_column="target")
print(f"Average mutual information: {avg_mi:.4f} bits")
Per-Feature Scores
If you need the individual MI score per feature, compute it directly and inspect the array:
import pandas as pd
from sklearn.feature_selection import mutual_info_classif
frame = pd.DataFrame(
{
"feat1": [0, 1, 1, 0, 1, 0],
"feat2": [5.1, 5.0, 4.9, 5.2, 5.1, 5.0],
"target": [0, 1, 1, 0, 1, 0],
}
)
scores = mutual_info_classif(frame[["feat1", "feat2"]], frame["target"])
for column, score in zip(["feat1", "feat2"], scores):
print(column, score)
Use the per-feature scores to filter low-signal columns before passing the DataFrame back through Swarmauri.
Tips
- Normalize or discretize continuous features when comparing very different scales; mutual information is sensitive to distribution assumptions.
- Handle missing values before calling
calculate;mutual_info_classifdoes not accept NaNs. - Binary targets work out of the box; for multi-class targets, ensure
target_columncontains integer encodings.
Want to help?
If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.
Metadata
Release files for swarmauri_measurement_mutualinformation 0.9.3
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 |
|---|---|---|---|---|
| swarmauri_measurement_mutualinformation-0.9.3.tar.gz | 7.5 kB | Without provenance | Details for swarmauri_measurement_mutualinformation-0.9.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarmauri_measurement_mutualinformation-0.9.3-py3-none-any.whl | Python 3 | none | any | Details for swarmauri_measurement_mutualinformation-0.9.3-py3-none-any.whl |
Total release size: 16.2 kB
Release files / swarmauri_measurement_mutualinformation-0.9.3.tar.gz
| Download URL | swarmauri_measurement_mutualinformation-0.9.3.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a43ff220a7439d9515b76dadb41e5976c1a5b3351fffea0f5a8d5db5cad7057
|
|
BLAKE2b-256 checksum How to use checksums |
4d83a3a722aa026aef0d4e0199e2356d8fa2085382e38ade67e2cac02e957fbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / swarmauri_measurement_mutualinformation-0.9.3-py3-none-any.whl
| Download URL | swarmauri_measurement_mutualinformation-0.9.3-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a041a0071c6f0580b87daf834326d9ed73e86763daa43994f9ead5e3465770d4
|
|
BLAKE2b-256 checksum How to use checksums |
ca7053b7b2820d3f836ca4b05cf4031558b213146e28bfa0262276f41fba12cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for swarmauri_measurement_mutualinformation 0.9.3
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.