Skip to main content

A Python library for automated feature engineering tailored to clustering in customer personality analysis within the retail industry.

Project description

customer_personality_analysis_afe

Automated Feature Engineering Framework for Customer Personality Analysis in the Retail Industry

Overview

This repository provides a one-stop solution for data cleaning, GPT-powered transformations, feature engineering, and feature reduction—all tuned specifically for Clustering tasks, useful for Customer Personality Analysis in a retail setting.

With a single orchestrator pipeline, users can:

  • Drop or impute problematic columns,
  • Automatically generate Python code via GPT to transform their DataFrame,
  • Engineer advanced features (e.g., frequency encoding, pairwise interactions, scaling),
  • Perform Ant Colony Optimization (ACO) for feature reduction.

Key Features

  1. Data Cleaning

    • Drop single-value columns
    • Impute missing values (median/mode)
    • Convert binary columns to boolean
    • Winsorize outliers at 1st/99th percentile
  2. GPT Transformations

    • Summarize DataFrame schema and produce a “checklist”
    • Generate dynamic Python code in <start_code> ... <end_code> blocks
    • Execute GPT-generated transformations automatically on your DataFrame
  3. Feature Engineering

    • Frequency encode categorical columns
    • Transform boolean columns to numeric “weights”
    • Create pairwise interactions (squared, sqrt, products, divisions)
    • Standard scaling for numerical features
  4. Feature Reduction

    • Ant Colony Optimization to pick an optimal subset of features
    • Evaluate subset quality using Calinski-Harabasz (CHI) and Davies-Bouldin (DBI)
  5. Orchestrator Pipeline

    • A single class (AutomatedPipeline) that ties all steps into a .run_pipeline() call
    • Configurable toggles to skip or include GPT transformations, advanced feature ops, or ACO-based reduction

Installation

  1. Clone or Download this repo:
    git clone https://github.com/ethandt210/customer_personality_analysis_afe.git
    cd customer_personality_analysis_afe
    
  2. Install via pip:
    pip install -e .
    

Usage Example

import pandas as pd
from clustering_afe import automated_feature_engineering

# Suppose you have a CSV file
df_raw = pd.read_csv("customer_marketing_data.csv")

# Provide your OpenAI API key to enable GPT transformations
my_api_key = "sk-YourOpenAIKeyHere"

# Create the pipeline
afe = automated_feature_engineering(df_raw, my_api_key)

# Run the entire pipeline:
#   1) Data Cleaning
#   2) GPT transformations
#   3) Feature transformations
#   4) Feature reduction (ACO)
df_final = afe.run_pipeline(
    use_gpt=True, 
    do_feature_engineering=True, 
    do_aco=True
)

print("Final DataFrame Shape:", df_final.shape)
print("Selected Features:", pipeline.meta_info.get("best_features"))

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

clustering_afe-1.1.5.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

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

clustering_afe-1.1.5-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file clustering_afe-1.1.5.tar.gz.

File metadata

  • Download URL: clustering_afe-1.1.5.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.6

File hashes

Hashes for clustering_afe-1.1.5.tar.gz
Algorithm Hash digest
SHA256 4a6d83134b9e29de69f90d4a4e137465f1210ac07d6e4c2b0911ce93aeacdbd0
MD5 f0693d2359330ef0f6b98ba04638015f
BLAKE2b-256 cd0db8d96fec6c4829350358471099c3dfddb2e3e81c384f418ad2bbb5b6ec1f

See more details on using hashes here.

File details

Details for the file clustering_afe-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: clustering_afe-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.6

File hashes

Hashes for clustering_afe-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 617c460b673c45960e39505ac7be1e723bdc75b258460de24f8bfe35cc0a2ae1
MD5 143ce2be101520d70614921a061d34bc
BLAKE2b-256 a3a346a8ea86edcb13b7090a8ff2457a1fbfe1f0998c2210ca2005b10a4b5f33

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