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.3.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.3.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: featureexpand-0.3.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.3.0.tar.gz
Algorithm Hash digest
SHA256 21a733856f55b844f148d4f240a4df5c6533999f69a7a14f82542b664f84ba2a
MD5 f66aefaf59d28ee9f8b0ac8eb4778641
BLAKE2b-256 50ca83febf7d21b97bccf766af1c2e300e89d0f50e79ca796ae269c4727e1c6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: featureexpand-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d38df46e2732dbc3de2234e6d93c323bd6e381dd8875b5941dbe5686fa13c216
MD5 907a252d797679779fe59ffc391d398f
BLAKE2b-256 7c5642eec72d6b43030b3bfb1befc392d1b0b6ed5d91de416871a5b2b0ba4c8d

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