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.
- Columns with only two unique values are encoded using
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf2a4476de3dbb5df564f55cca5ab34b5a787bab51feb3b482bfee62211f256
|
|
| MD5 |
b30bb76b45b71ae82a66d7c643f92d41
|
|
| BLAKE2b-256 |
5c70acec741ef2c4a20da5ae5a10b9b989024bec06667774fc0b3f521bac07dc
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d98730d102e492cc281b411fdbbf3c434f0066cee7babdb7599c52f7e829380f
|
|
| MD5 |
fe0bdba59b682c2040bdc7014ea801b3
|
|
| BLAKE2b-256 |
c43de17b155494551ffe252cd5a20501a77fcaab7034f65ff41f63ccd2694a5b
|