Skip to main content

hash tables for vectorizing text-based documents

Project description

If you have documents with class labels, and you want to create numeric representations of those documents that maximize inter-class differences, then this package is for you. This package provides vectorizing hash tables that quickly transform your text, optimizing for the maximum distance between document-class vectors.

This project has a C++ backend with a python interface, allowing for maximum speed and maximum interopability.

Installation

To install, use pip:

pip install vhash

Minimum Working Example

This package follows the conventions of scikit-learn to provide an intuitive and familiar interface.

from typing import Any

from nptyping import NDArray

from vhash import VHash


 # sample documents: each item in the list is its own document
 docs = [
     'hi, my name is Mike',
     'hi, my name is George',
     'hello, my name is Mike',
 ]

 # class labels for each document
 labels = [1, 0, 1]

 # create & train model
 vhash = VHash().fit(docs, labels)

 # create numeric representation (2D float array)
 numeric: NDArray[(Any, Any), float] = vhash.transform(docs)

Metrics

To see how this text transformer compares to BERT, check out the sample notebook, where we show how vhash outperforms sBERT on a sentiment analysis task.

Documentation

To get started, check out the docs!

If you will be contributing to this repo, checkout the developer guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vhash-0.0.27.tar.gz (14.2 kB view details)

Uploaded Source

File details

Details for the file vhash-0.0.27.tar.gz.

File metadata

  • Download URL: vhash-0.0.27.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for vhash-0.0.27.tar.gz
Algorithm Hash digest
SHA256 5c67fd99bd9e96cc8b164558649d6281dbe4ee41b3cd19b00d91ac000afa88fd
MD5 b61766f1ef84250a34443e4e0d51adcb
BLAKE2b-256 0e4dfb436cd775d3a9920d21cb300c9b7fe168e9a6aca903268471ce7f97293c

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