llm-feat
Automatically generate feature engineering code for pandas DataFrames using LLMs. Get context-aware, target-specific features that understand your domain.
Installation
pip install llm-feat
Quick Start
import pandas as pd
import llm_feat
llm_feat.set_api_key("your-openai-api-key") # or set OPENAI_API_KEY env var
# Your data
df = pd.DataFrame({
'income': [50000, 60000, 70000],
'expenses': [30000, 35000, 40000],
'target': [1, 0, 1]
})
# Metadata describing your columns
metadata_df = pd.DataFrame({
'column_name': ['income', 'expenses', 'target'],
'description': ['Annual income', 'Annual expenses', 'Binary target'],
'data_type': ['numeric', 'numeric', 'numeric'],
'label_definition': [None, None, '1 if positive, 0 if negative']
})
# Generate features
code = llm_feat.generate_features(df, metadata_df, mode='code')
print(code)
Generated Code:
import numpy as np
df['income_to_expense_ratio'] = np.where(df['expenses'] != 0, df['income'] / df['expenses'], np.nan)
df['savings'] = df['income'] - df['expenses']
df['savings_to_income_ratio'] = np.where(df['income'] != 0, df['savings'] / df['income'], np.nan)
Feature Reports
Get detailed explanations of why each feature was generated:
code, report = llm_feat.generate_features(
df, metadata_df, mode='code', return_report=True
)
print(report)
Example Report:
FEATURE REPORT
==============
1. DOMAIN UNDERSTANDING:
- Problem: Predicting binary target based on income and expenses
- Key relationships: Income-to-expense ratios indicate financial health
2. GENERATED FEATURES EXPLANATION:
- Feature: income_to_expense_ratio
Rationale: Higher ratios indicate better financial stability
Domain Relevance: Directly related to predicting positive outcomes
Direct Mode
Add features directly to your DataFrame:
df_with_features = llm_feat.generate_features(
df, metadata_df, mode='direct', model='gpt-4o-mini'
)
Key Features
- Context-aware: Uses column descriptions to generate relevant features
- Target-aware: Generates features specific to your prediction task
- Categorical support: Automatic encoding for categorical columns
- Jupyter integration: Code auto-injected into next cell
- Feature reports: Understand the reasoning behind each feature
Documentation
- API Reference - Complete parameter documentation and examples
- Examples - Jupyter notebook examples
- Changelog - Version history
Development
git clone https://github.com/codeastra2/llm-feat.git
cd llm-feat
conda create -n llm_feat_310 python=3.10 -y
conda activate llm_feat_310
poetry install
poetry run pytest
License
MIT License - see LICENSE file for details.
Author
Srinivas Kumar - @codeastra2
Links
Metadata
Release files for llm-feat 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_feat-0.2.3.tar.gz | 13.4 kB | With provenance | Details for llm_feat-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_feat-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for llm_feat-0.2.3-py3-none-any.whl |
Total release size: 27.4 kB
Release files / llm_feat-0.2.3.tar.gz
| Download URL | llm_feat-0.2.3.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12a31b37684805da25179099f2e664b0ee815d59b1779d139da3a2d8e891480c
|
|
BLAKE2b-256 checksum How to use checksums |
0293b8f68f1234c4d6c07748064350a668a05442419a7f4a82ff52cb7cc7cb35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 5, 2026.
Transparency logRelease files / llm_feat-0.2.3-py3-none-any.whl
| Download URL | llm_feat-0.2.3-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d2c1bb42e8b794bba22e33aa1a25bffa7bdb80db968f01f20fa9fcde3061749
|
|
BLAKE2b-256 checksum How to use checksums |
906f0d977c31e6d767e4255e9f30bd11cb53474cb99532deb15a6b5abea9a553
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 5, 2026.
Transparency logSecurity for llm-feat 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for llm_feat-0.2.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.