Skip to content

Wrong total_count if feature is not of dtype object/str #2

Open

Description

@volksen

Hi,

thanks for project. I found a small error when using the BayesEncoding with a feature column which dtype is numeric. I know that the library is indended to encode categorical columns but nevertheless the dtype could be wrong by mistake or one maybe still want to encode numeric values.

The problem is, that

entry=entry.groupby(feature).agg('sum').reset_index()
entry['total_count']=entry.sum(axis=1)

sums the value of the feature itself to the total_count.

An easy fix would be to reset the index after the calculation of the total_count:

    entry=entry.groupby(feature).agg('sum')
    entry['total_count']=entry.sum(axis=1)
    entry = entry.reset_index()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions