Skip to main content

Feature Selection with Hybrid TFFS

Description

The get_list_feature_tffs_hybrid function is used for feature selection based on high occurrence frequency during the Random Forest construction process, while also supporting integration with traditional feature selection methods.

Syntax

get_list_feature_tffs_hybrid(df, number_of_runs, n_estimators, percent, type=None, percent_hybrid=None)

Parameters

Parameter Data Type Description
df DataFrame DataFrame containing input data (dependent variable in the first column).
number_of_runs int Number of Random Forest runs to determine important feature frequencies.
n_estimators int Number of trees in the Random Forest.
percent float Percentage of features selected based on the highest occurrence frequency.
type str, optional (Optional) Traditional feature selection method for integration.
percent_hybrid float, optional (Optional) Percentage of features retained after hybrid selection.

Valid Values for type

If type is used, one of the following feature selection methods can be chosen:

type Value Feature Selection Method
"MI" Mutual Information
"PC" Pearson Correlation
"FS" Fisher Score
"BW" Backward Selection
"FW" Forward Selection
"RC" Recursive Feature Elimination (RFE)
"LS" Lasso Regression

Usage

Using Random Forest Only for Feature Selection

import pandas as pd
from sff.app import get_list_feature_tffs_hybrid

# Sample DataFrame
data = {
    "Class": [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
    "Feature1": [5, 8, 6, 7, 5, 8, 6, 7, 5, 8],
    "Feature2": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    "Feature3": [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]
}
df = pd.DataFrame(data)

# Run function
selected_features = get_list_feature_tffs_hybrid(df, number_of_runs=10, n_estimators=100, percent=20)
print("Selected Features:", selected_features)

Integrating with Mutual Information (MI)

selected_features = get_list_feature_tffs_hybrid(df, number_of_runs=10, n_estimators=100, percent=75, type="MI", percent_hybrid=50)
print("Selected Features:", selected_features)

Integrating with Recursive Feature Elimination (RFE)

selected_features = get_list_feature_tffs_hybrid(df, number_of_runs=15, n_estimators=200, percent=75, type="RC", percent_hybrid=50)
print("Selected Features:", selected_features)

Integrating with Mutual Information (MI) - Example Code

import pandas as pd
from sff.app import get_list_feature_tffs_hybrid

# Sample DataFrame
data = {
    "Class": [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
    "Feature1": [5, 8, 6, 7, 5, 8, 6, 7, 5, 8],
    "Feature2": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    "Feature3": [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]
}
df = pd.DataFrame(data)

# Run function
selected_features = get_list_feature_tffs_hybrid(df, 5, 20, 75, "MI", 50)
print("Selected Features:", selected_features)

Notes

  • If type is not provided, the function will use only Random Forest for feature selection.
  • If type is provided, the function will integrate Random Forest with the specified traditional method for optimal feature selection.
  • percent_hybrid is applicable only when type is used.
  • Note: percent (4th parameter) must be greater than percent_hybrid.
  • Note: df must have the class column as the first column.

Release files for sff 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sff 1.0.0
File Size Uploaded
sff-1.0.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sff 1.0.0
File Interpreter ABI Platform
sff-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / sff-1.0.0.tar.gz

Download URL sff-1.0.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c5b054e1d0414262ad737f06620bd95da461b8bd53ca4e0efe03866d8fd2b9de
BLAKE2b-256 checksum
How to use checksums
ce8a83b43750423d9eef7ae20b5104d575e00c92a146a1ee49964988c266218e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.5

Release files / sff-1.0.0-py3-none-any.whl

Download URL sff-1.0.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c25cae9cd78577ca5652ea4087261cfd7e8bbeebff3f9193baf5571c089cf5ff
BLAKE2b-256 checksum
How to use checksums
1d377ef3705da2e07e6bb871c613fefc8548ef69f31fa1dd21925d6ed72857d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page