Metadata-Version: 2.4
Name: prob-target-encoder
Version: 0.1.0
Summary: A probability-weighted target encoder.
Author-email: Your Name <you@example.com>
License: MIT License
        
        Copyright (c) 2026 Rishabh
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pandas
Dynamic: license-file

# Probability Target Encoder

A Python library for encoding categorical features using a probability-weighted target encoding technique.

This encoder extends the traditional target encoder by incorporating the probability that a target value exceeds the global target mean, and then uses the variance to increase confidence, producing encodings that capture both the average target value and the likelihood of above-average outcomes which has a higher confidence when the data isn't varied. 

# Features
- Handles categorical variables with numerical targets.
- Supports missing values.
- Encodes unseen categories using a fallback.
- Simple API with fit(), transform() and fit_transform() methods.
- Lightweight implementation with minimal dependencies.

# Installation
```
pip install prob-target-encoder
```
# Quick Start
```
from prob_target_encoder import ProbabilityTargetEncoder

encoder = ProbabilityTargetEncoder()

encoder.fit(train_column, train_target)

encoded_train = encoder.transform(train_column)
encoded_test = encoder.transform(test_column)
```
# Example
```
import pandas as pd
from prob_target_encoder import ProbabilityTargetEncoder

X = pd.Series(["A", "B", "A", "C", "B"])
y = pd.Series([10, 20, 15, 8, 25])

encoder = ProbabilityTargetEncoder()
encoder.fit(X, y)

encoded = encoder.transform(X)

print(encoded)
```
# How It Works
For each category, the encoder computes:

The mean target value for that category.
The probability that the target exceeds the global target mean.
the variance of the target value for each category.
An encoding derived from these statistics.

# Requirements
Python 3.9+
pandas

# License

This project is licensed under the MIT License.
