Skip to main content

Cane - Categorical Attribute traNsformation Environment

Project description

Cane - Categorical Attribute traNsformation Environment

CANE is a simpler but powerful preprocessing method for machine learning.

At the moment offers 3 preprocessing methods:

--> The Percentage Categorical Pruned (PCP) merges all least frequent levels (summing up to "perc" percent) into a single level as presented in (https://doi.org/10.1109/IJCNN.2019.8851888), which, for example, can be "Others" category. It can be useful when dealing with several amounts of categorical information (e.g., city data).

--> The Inverse Document Frequency (IDF) codifies the categorical levels into frequency values, where the closer to 0 means, the more frequent it is (https://ieeexplore.ieee.org/document/8710472).

--> Finally it also has implemented a simpler standard One-Hot-Encoding method.

Instalation

To install this package please run the following command

pip install cane 

It is still in test version, so any feedback would be appreciated

For questions and other suggestions contact luis.matos@dsi.uminho.pt

Example

import pandas as pd
import cane
x = [k for s in ([k] * n for k, n in [('a', 30000), ('b', 50000), ('c', 70000), ('d', 10000), ('e', 1000)]) for k in s]
df = pd.DataFrame({f'x{i}' : x for i in range(1, 13)})

dataPCP, dicionary = cane.pcp(df)  # uses the PCP method and only 1 core
dataPCP, dicionary = cane.pcp(df, n_coresJob=2)  # uses the PCP method and only 2 cores
dataIDF = cane.idf(df)  # uses the IDF method and only 1 core
dataIDF = cane.idf(df, n_coresJob=2)  # uses the IDF method and only 2 core

dataH = cane.one_hot(df)  # without a column prefixer
dataH2 = cane.one_hot(df, column_prefix='column')  # it will use the original column name prefix
# (useful for when dealing with id number columns)
dataH3 = cane.one_hot(df, column_prefix='customColName')  # it will use a custom prefix defined by
# the value of the column_prefix
dataH4 = cane.one_hot(df, column_prefix='column', n_coresJob=2)  # it will use the original column name prefix
# (useful for when dealing with id number columns)
# with 2 cores

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

cane-0.0.1.4.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

cane-0.0.1.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file cane-0.0.1.4.tar.gz.

File metadata

  • Download URL: cane-0.0.1.4.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for cane-0.0.1.4.tar.gz
Algorithm Hash digest
SHA256 3d1bc1c1d10cdc182c33fede94d40dd5c829d2b7c170be9afc7c74b192cf71e1
MD5 8527bdab0c0634d7ff766901532bd359
BLAKE2b-256 a309bf89c2c2cfa252fa06bbad45b3ee6dbcc7530c6c2ec46ec04cdc909dba85

See more details on using hashes here.

File details

Details for the file cane-0.0.1.4-py3-none-any.whl.

File metadata

  • Download URL: cane-0.0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for cane-0.0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c93626e847e1f7b72ed8326d1c5f033d1f346e48e5f6b690fa0a1a3f87636fa9
MD5 99f67d8287e4dd207e0be6d2252e8383
BLAKE2b-256 eb2e9119b7b9ca21182287562817b5ed9e8ca459bd8c226ae6b8238a1aafeb0c

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