Skip to main content

A package for encoding and scaling data for ML pipelines

Project description

easyformer

A Python package for creating machine learning pipelines that standardize numerical columns and encode categorical columns using LabelEncoder or OneHotEncoder based on the number of unique values.

Installation

You can install the package from PyPI using pip:

pip install easyformer

Usage

1. Import the Package

from easyformer import create_pipeline
import pandas as pd

2. Load Your Data

# Example: Load a CSV file into a pandas DataFrame
data = pd.read_csv('your_data.csv')

3. Create the Pipeline

pipeline = create_pipeline(data)

4. Fit and Transform Your Data

# Fit the pipeline to your data and transform it
transformed_data = pipeline.fit_transform(data)

5. (Optional) Convert Transformed Data Back to a DataFrame

# If you need the transformed data as a DataFrame
transformed_df = pd.DataFrame(transformed_data, columns=pipeline.named_steps['preprocessor'].get_feature_names_out())
print(transformed_df.head())

Example

Here’s a full example that puts everything together:

from easyformer import create_pipeline
import pandas as pd

# Load your data
data = pd.read_csv('your_data.csv')

# Create the pipeline
pipeline = create_pipeline(data)

# Fit and transform your data
transformed_data = pipeline.fit_transform(data)

# Optionally convert the transformed data back to a DataFrame
transformed_df = pd.DataFrame(transformed_data, columns=pipeline.named_steps['preprocessor'].get_feature_names_out())
print(transformed_df.head())

Description

The easyformer package automates the preprocessing steps for machine learning pipelines by:

  • Standardizing Numerical Columns: All numerical columns are scaled using StandardScaler.
  • Encoding Categorical Columns:
    • Columns with only two unique values are encoded using LabelEncoder.
    • Columns with more than two unique values are one-hot encoded using OneHotEncoder.
  • Removing Original Categorical Columns: The original categorical columns are dropped after encoding.

License

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

Contributing

If you would like to contribute to this package, please submit a pull request or open an issue on the GitHub repository.

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

easyformer-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

easyformer-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file easyformer-0.1.0.tar.gz.

File metadata

  • Download URL: easyformer-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for easyformer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 daf2a4476de3dbb5df564f55cca5ab34b5a787bab51feb3b482bfee62211f256
MD5 b30bb76b45b71ae82a66d7c643f92d41
BLAKE2b-256 5c70acec741ef2c4a20da5ae5a10b9b989024bec06667774fc0b3f521bac07dc

See more details on using hashes here.

File details

Details for the file easyformer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: easyformer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for easyformer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d98730d102e492cc281b411fdbbf3c434f0066cee7babdb7599c52f7e829380f
MD5 fe0bdba59b682c2040bdc7014ea801b3
BLAKE2b-256 c43de17b155494551ffe252cd5a20501a77fcaab7034f65ff41f63ccd2694a5b

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