🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

scikit-ptm-fs

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scikit-ptm-fs

A Python package for integrating scikit-learn feature selection with multi-label problem transformation methods.

0.12
Source
PyPI
Maintainers
1

Scikit-PTM-FS

PyPI version Python License: MIT

Scikit-PTM-FS is a Python library that enables seamless integration of scikit-learn feature selection methods with multi-label classification via problem transformation methods (PTMs). The framework enables transformation-aware feature selection without requiring classification stages, allowing researchers to analyze the behavior of FS methods across various PTMs.

📦 Installation

pip install scikit-ptm-fs

🚀 Usage Example

Here is a basic example of how to apply a feature selection method within a problem transformation method using Scikit-PTM-FS:

from scikit_ptm_fs.problem_transformation import LabelPowerset
from sklearn.feature_selection import SelectKBest, f_classif

# Example feature and label matrices (replace with your own)
# X = ...  # shape (n_samples, n_features)
# y = ...  # shape (n_samples, n_labels)

# Step 1: Define a scikit-learn selector
selector = SelectKBest(score_func=f_classif, k=5)

# Step 2: Wrap it using the LabelPowerset PTM
lp_selector = LabelPowerset(selector=selector, require_dense=[False, True])

# Step 3: Apply feature selection
X_selected = lp_selector.fit_transform(X, y)

# Step 4: Get selected feature indices
selected_indices = lp_selector.get_support()
print("Selected features:", selected_indices)

indices = np.where(lp_selector.get_support())[0]
print("The Number of Selected Features:", len(indices))

💡 You can use other PTMs like BinaryRelevance, PPT, or PairwiseComparison similarly.

🧠 Supported Problem Transformation Methods (PTMs)

  • Binary Relevance (BR) — One-vs-All decomposition.
  • Label Powerset (LP) — Unique labelset encoding.
  • Pairwise Comparison (PW) — One-vs-One label pair modeling.
  • Pruned Problem Transformation (PPT) — Labelset pruning before transformation.
  • Entropy-based Label Assignment (ELA) — Copy-based transformation for NLP.

📄 License

This project is licensed under the MIT License.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts