Skip to main content

leave-one-out-encoder

Leave one out coding for categorical features

See the source for this project here: https://github.com/welfare520/leave-one-out-encoder.

Getting Started

Installing

$ pip install loo_encoder

Example

Fit encoder according to X and y, and then transform it.

from loo_encoder.encoder import LeaveOneOutEncoder
import pandas as pd
import numpy as np


enc = LeaveOneOutEncoder(cols=['gender', 'country'], handle_unknown='impute', sigma=0.02, random_state=42)

X = pd.DataFrame(
    {
        "gender": ["male", "male", "female", "male"],
        "country": ["Germany", "USA", "USA", "UK"],
        "clicks": [10, 33, 47, 21]
    }
)

y = pd.Series([150, 250, 300, 100], name="orders")

df_train = enc.fit_transform(X=X, y=y, sample_weight=X['clicks'])

Perform the transformation to new categorical data.

X_val = pd.DataFrame(
    {
        "gender": ["unknown", "male", "female", "male"],
        "country": ["Germany", "USA", "Germany", "Japan"]
    }
)

df_test = enc.transform(X=X_val)

Metadata

Release files for loo_encoder 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for loo_encoder 0.0.9
File Size Uploaded
loo_encoder-0.0.9.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for loo_encoder 0.0.9
File Interpreter ABI Platform
loo_encoder-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / loo_encoder-0.0.9.tar.gz

Download URL loo_encoder-0.0.9.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0aae6b3a6da341b0d97e1728ab627027be6ef3351ab4bd4a82b946a1277edf47
BLAKE2b-256 checksum
How to use checksums
971393050a7a05b6ce41a375451b16817b34a3734480824bcfdd3d2fe8b98edf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

Release files / loo_encoder-0.0.9-py3-none-any.whl

Download URL loo_encoder-0.0.9-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd9cd2836cdf95b561928ead4d7d37c450680c385ec4c4b436c6f30354a8c47c
BLAKE2b-256 checksum
How to use checksums
3af437eeb3d8feb8c55c07b6460e8dd9c46ff0aa1f780afe9a1a884734444230
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page