Skip to main content

A powerful Python library for automatic feature engineering using logical formula simplification

Project description

FeatureExpand

PyPI version License: MIT Python 3.8+ Documentation Status

FeatureExpand is a powerful Python library designed to enhance your datasets through automatic feature engineering using logical formula simplification. Whether you're working on machine learning, data analysis, or any data-driven application, FeatureExpand helps you extract maximum value from your data by generating optimized boolean and continuous features.

✨ Features

  • Automatic Feature Engineering: Generates new features using logical formulas optimized by the Exactor API
  • Scikit-learn Compatible: Fully compatible with scikit-learn pipelines and transformers
  • Boolean & Continuous Features: Supports both boolean logic features and continuous relaxations
  • Model Booster: LinearModelBooster automatically selects the best model among linear, polynomial, and logic-guided regression
  • Smart Caching: Cached API calls for improved performance
  • Flexible Configuration: Customizable precision, depth, and feature generation strategies

🚀 Quick Start

Installation

pip install featureexpand

Basic Usage

import numpy as np
import pandas as pd
from featureexpand import FeatureExpander, LinearModelBooster
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score

# Create sample data
X = pd.DataFrame({
    'feature1': np.random.rand(100),
    'feature2': np.random.rand(100),
})
y = (X['feature1'] > 0.5) & (X['feature2'] < 0.5)  # Boolean logic target

# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Use FeatureExpander
expander = FeatureExpander(
    token="your_exactor_api_token",  # Get from https://www.booloptimizer.com
    deep=2,  # Bits per feature
    environment="PROD"
)

# Fit and transform
X_train_expanded = expander.fit_transform(X_train, y_train)
X_test_expanded = expander.transform(X_test)

print(f"Original features: {X_train.shape[1]}")
print(f"Expanded features: {X_train_expanded.shape[1]}")
print(f"Generated formula: {expander.formula_string_}")

Using LinearModelBooster

from featureexpand import LinearModelBooster

# Automatically selects best model (Linear, Polynomial, or Logic-Guided)
booster = LinearModelBooster(
    token="your_exactor_api_token",
    poly_degrees=[2, 3],
    logic_depths=[1, 2],
    cv=5,
    scoring='r2'
)

# Fit and predict
booster.fit(X_train, y_train)
y_pred = booster.predict(X_test)

# View results
booster.summary()
print(f"Best model: {booster.best_model_name_}")
print(f"Best score: {booster.best_score_:.4f}")

📚 Documentation

For comprehensive documentation, including tutorials, API reference, and examples, visit:

🔑 API Token

FeatureExpand uses the Exactor API for boolean formula optimization. You can:

  1. Get a free token at https://www.booloptimizer.com
  2. Set it as an environment variable: export EXACTOR_API_TOKEN=your_token
  3. Pass it directly: FeatureExpander(token="your_token")

💡 Use Cases

  • Machine Learning: Enhance model performance with engineered features
  • Binary Classification: Extract logical patterns from data
  • Feature Discovery: Automatically discover feature interactions
  • Model Interpretation: Understand data relationships through boolean formulas
  • Trading Signals: Generate forex/stock trading signals (see examples/forex/)

🛠️ Requirements

  • Python >= 3.8
  • NumPy >= 1.19.0
  • Pandas >= 1.1.0
  • Scikit-learn >= 0.24.0
  • Requests >= 2.25.0

📦 What's Included

  • FeatureExpander: Core transformer for automatic feature generation
  • LinearModelBooster: Automatic model selection with feature expansion
  • Neural utilities: Neural network guidance for feature engineering
  • Utility functions: Encoding, formula conversion, and migration tools

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Powered by the Exactor API for boolean formula optimization
  • Built with Scikit-learn
  • Inspired by research in boolean function minimization and automatic feature engineering

📞 Contact


Made with ❤️ for the ML community

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

featureexpand-0.4.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

featureexpand-0.4.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file featureexpand-0.4.0.tar.gz.

File metadata

  • Download URL: featureexpand-0.4.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.3

File hashes

Hashes for featureexpand-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9b324407fa25d6847c50ac2797ca5c7df90bf437bd0937dc1ceffe983ff3dac3
MD5 4c4058ba056c40a7cd30808bab998bfa
BLAKE2b-256 6c838d5468ddb106a123a841860a372c5d6654fdfe8c10b8e0f11aa352b63e5f

See more details on using hashes here.

File details

Details for the file featureexpand-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: featureexpand-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.3

File hashes

Hashes for featureexpand-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f093e773af914c51bdf2dfacd9a8312aa376ee99e34fe470887e18d3ead68625
MD5 dcbba5c96e1c81e8f2512bef3b3f5efb
BLAKE2b-256 816472257fcfa8543cead8ebbcb1495028b7fcf4828774b3e84fdb756e2954d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page