swarmauri_measurement_mutualinformation 0.6.0.dev154__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swarmauri_measurement_mutualinformation-0.6.0.dev154/PKG-INFO +21 -0
- swarmauri_measurement_mutualinformation-0.6.0.dev154/README.md +1 -0
- swarmauri_measurement_mutualinformation-0.6.0.dev154/pyproject.toml +59 -0
- swarmauri_measurement_mutualinformation-0.6.0.dev154/swarmauri_measurement_mutualinformation/MutualInformationMeasurement.py +43 -0
- swarmauri_measurement_mutualinformation-0.6.0.dev154/swarmauri_measurement_mutualinformation/__init__.py +14 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: swarmauri_measurement_mutualinformation
|
|
3
|
+
Version: 0.6.0.dev154
|
|
4
|
+
Summary: Swarmauri Mutual Information Measurement Community Package.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Author: Jacob Stewart
|
|
7
|
+
Author-email: jacob@swarmauri.com
|
|
8
|
+
Requires-Python: >=3.10,<3.13
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
|
15
|
+
Requires-Dist: scikit-learn (>=1.5.2,<2.0.0)
|
|
16
|
+
Requires-Dist: swarmauri_base (>=0.6.0.dev154,<0.7.0)
|
|
17
|
+
Requires-Dist: swarmauri_core (>=0.6.0.dev154,<0.7.0)
|
|
18
|
+
Project-URL: Repository, http://github.com/swarmauri/swarmauri-sdk
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# Swarmauri Example Community Package
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Swarmauri Example Community Package
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "swarmauri_measurement_mutualinformation"
|
|
3
|
+
version = "0.6.0.dev154"
|
|
4
|
+
description = "Swarmauri Mutual Information Measurement Community Package."
|
|
5
|
+
authors = ["Jacob Stewart <jacob@swarmauri.com>"]
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
repository = "http://github.com/swarmauri/swarmauri-sdk"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"License :: OSI Approved :: Apache Software License",
|
|
11
|
+
"Programming Language :: Python :: 3.10",
|
|
12
|
+
"Programming Language :: Python :: 3.11",
|
|
13
|
+
"Programming Language :: Python :: 3.12"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.poetry.dependencies]
|
|
17
|
+
python = ">=3.10,<3.13"
|
|
18
|
+
|
|
19
|
+
# Swarmauri
|
|
20
|
+
swarmauri_core = {version = "^0.6.0.dev154"}
|
|
21
|
+
swarmauri_base = {version = "^0.6.0.dev154"}
|
|
22
|
+
|
|
23
|
+
# Dependencies
|
|
24
|
+
scikit-learn = "^1.5.2"
|
|
25
|
+
pandas = "^2.2.3"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
[tool.poetry.group.dev.dependencies]
|
|
30
|
+
flake8 = "^7.0"
|
|
31
|
+
pytest = "^8.0"
|
|
32
|
+
pytest-asyncio = ">=0.24.0"
|
|
33
|
+
pytest-xdist = "^3.6.1"
|
|
34
|
+
pytest-json-report = "^1.5.0"
|
|
35
|
+
python-dotenv = "*"
|
|
36
|
+
requests = "^2.32.3"
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["poetry-core>=1.0.0"]
|
|
40
|
+
build-backend = "poetry.core.masonry.api"
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
norecursedirs = ["combined", "scripts"]
|
|
44
|
+
|
|
45
|
+
markers = [
|
|
46
|
+
"test: standard test",
|
|
47
|
+
"unit: Unit tests",
|
|
48
|
+
"integration: Integration tests",
|
|
49
|
+
"acceptance: Acceptance tests",
|
|
50
|
+
"experimental: Experimental tests"
|
|
51
|
+
]
|
|
52
|
+
log_cli = true
|
|
53
|
+
log_cli_level = "INFO"
|
|
54
|
+
log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
|
|
55
|
+
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
56
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
57
|
+
|
|
58
|
+
[tool.poetry.plugins."swarmauri.measurements"]
|
|
59
|
+
MutualInformationMeasurement = "swarmauri_measurement_mutualinformation.MutualInformationMeasurement:MutualInformationMeasurement"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from sklearn.feature_selection import mutual_info_classif
|
|
4
|
+
from swarmauri_core.ComponentBase import ComponentBase
|
|
5
|
+
from swarmauri_base.measurements.MeasurementBase import MeasurementBase
|
|
6
|
+
from swarmauri_base.measurements.MeasurementCalculateMixin import (
|
|
7
|
+
MeasurementCalculateMixin,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@ComponentBase.register_type(MeasurementBase, "MutualInformationMeasurement")
|
|
12
|
+
class MutualInformationMeasurement(MeasurementBase, MeasurementCalculateMixin):
|
|
13
|
+
"""
|
|
14
|
+
A Measurement class to calculate mutual information between features and a target column in a given dataset.
|
|
15
|
+
|
|
16
|
+
This class computes the mutual information between each feature in a DataFrame (excluding the target column)
|
|
17
|
+
and the target column itself, and returns the average mutual information score.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
type: Literal["MutualInformationMeasurement"] = "MutualInformationMeasurement"
|
|
21
|
+
unit: str = "bits"
|
|
22
|
+
|
|
23
|
+
def calculate(self, data: pd.DataFrame, target_column: str) -> float:
|
|
24
|
+
"""
|
|
25
|
+
Calculate the average mutual information between the features and the target column.
|
|
26
|
+
|
|
27
|
+
Parameters:
|
|
28
|
+
- data (pd.DataFrame): A DataFrame containing both the features and the target column.
|
|
29
|
+
|
|
30
|
+
- target_column (str) The name of the target column in the DataFrame.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
- float: The average mutual information across all feature columns.
|
|
34
|
+
"""
|
|
35
|
+
# Separate features from the target column
|
|
36
|
+
features_data = data.drop(columns=[target_column])
|
|
37
|
+
target_data = data[target_column]
|
|
38
|
+
|
|
39
|
+
# Calculate mutual information
|
|
40
|
+
mi = mutual_info_classif(features_data, target_data)
|
|
41
|
+
|
|
42
|
+
# Return the average mutual information across all features
|
|
43
|
+
return float(mi.mean()) # Output as a float
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .MutualInformationMeasurement import MutualInformationMeasurement
|
|
2
|
+
|
|
3
|
+
__version__ = "0.6.0.dev26"
|
|
4
|
+
__long_desc__ = """
|
|
5
|
+
|
|
6
|
+
# Swarmauri MutualInformation Plugin
|
|
7
|
+
|
|
8
|
+
This repository includes a MutualInformation of a Swarmauri Plugin.
|
|
9
|
+
|
|
10
|
+
Visit us at: https://swarmauri.com
|
|
11
|
+
Follow us at: https://github.com/swarmauri
|
|
12
|
+
Star us at: https://github.com/swarmauri/swarmauri-sdk
|
|
13
|
+
|
|
14
|
+
"""
|