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

Uploaded Python 3

File details

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

File metadata

  • Download URL: featureexpand-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 030df4ff3e0ca2a94d05f1d51040eb9885905dc3c2786d03c7a65a903b5f20bb
MD5 3cb88ca14906c94dd89cb53dafb7d542
BLAKE2b-256 53fec44b5fc97b547bb3957bf30a26cf6cdc42b8f0fd723fb9cf43fe90d82faf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: featureexpand-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a60184325e4523bbb87d985e5ea7ed8f65c93550d2add8d5d38aa6be319dc4bd
MD5 a2d5144cc27cffea18e45d868f2b00bd
BLAKE2b-256 ae999cf7825363823fe39f2559866e83ef9e0b7bd93e2d8646bb1bdcf9e4c600

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