A Python package for calculating information gain.
Project description
informationGainLibrary
This module helps you calculate Information Gain for categorical data.
Class
infoGain.calculate(data, target, criteria="gini", fIndex=True)
Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
data |
DataFrame | Dataset in pandas dataframe format | Required |
target |
String | Output column (the target variable) | Required |
fIndex |
Boolean | Specifies if the first column of the dataset is an index column | True |
criteria |
String | Splitting criteria to use: "gini" or "entropy" |
"gini" |
Description
- Calculates Information Gain for each feature/column in the dataset with respect to the target column.
- Useful for decision tree splitting based on entropy.
- Returns: A dictionary where keys are feature/column names and values are their corresponding Information Gain with respect to the target column.
Example Usage
from informationGain import infoGain
import pandas as pd
# Load dataset
data = pd.read_csv('your_dataset.csv')
# Initialize
ig = infoGain()
# Calculate Information Gain
result = ig.calculate(data, target='Output', fIndex=True)
print(result)
# Example Output:
# {'Feature1': 0.25, 'Feature2': 0.18, 'Feature3': 0.0}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
informationgain-2.1.0.tar.gz
(3.0 kB
view details)
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 informationgain-2.1.0.tar.gz.
File metadata
- Download URL: informationgain-2.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
846c0e6826eaf1cfc7708fd373b4278a2f02fb3b448a900385b28edcecb55dca
|
|
| MD5 |
82c7efa594fbdb0a33dce73aff1dfb0e
|
|
| BLAKE2b-256 |
e7ad90656357abd047bf374b2dfead3f22b98ae6163069b7a072478516e4dea1
|
File details
Details for the file informationgain-2.1.0-py3-none-any.whl.
File metadata
- Download URL: informationgain-2.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
972dc71e5e9644f10f7787b1881da90f546f9f5785c483996f196587c2b95812
|
|
| MD5 |
8f99503684f62be63b2e7245ad1eea84
|
|
| BLAKE2b-256 |
891b0e5879cd8e6f6309a2667f002c7a44bee96d9940b03a4e0be86e7e41ebc0
|