Skip to main content
# empathyMachines
> A standalone NLP sentiment classifier you can import as a module

## Purposes

1. Offer a batteries-included NLP classifier you can use either on it's own, or to make sentiment predictions as part of a broder NLP project (for example, when classifying customer messages, whether the customer is angry or not might help you determine if this is a compensation request, or a request to adjust their address.)
1. Have the entire sentiment prediction process scaffolded so you can feed in your own training corpus, and easily train an NLP sentiment classifier.

## How to use

1. `pip install empythy`
1.
```
from empythy import EmpathyMachines
nlp_classifier = EmpathyMachines()
nlp_classifier.train()
nlp_classifier.predict(text_string)
```

### Corpora included

#### NLTK Movie Reviews
The classic sentiment corpus, 2000 movie reviews already gathered by NLTK.

#### Assembling a custom Twitter sentiment corpus
[CrowdFlower](http://www.crowdflower.com/data-for-everyone) hosts a number of Twitter corpora that have already been graded for sentiment by panels of humans.

I aggregated together 6 of their corpora into a single, aggregated and cleaned corpus, with consistent scoring labels across the entire corpus. The cleaned corpus contains over 45,000 documents, with positive, negative, and neutral sentiments.


### Train on your own corpus

Feel free to train a classifier on your own corpus!

Two ways to do this

1. Read in a .csv file with header row containing "sentiment", "text", and optionally, "confidence"
- Pass the name of the .csv file to train, like so:
- `nlp_classifier.train(corpus='custom', corpus_path='path/to/custom/corpus.csv')`
1. Pass in an array of Python dictionaries, where each dictionary has attributes for "sentiment", "text", and optionally, "confidence"
- `nlp_classifier.train(corpus='custom', corpus_array=my_array_of_texts)`
- Two important parts to this, both `corpus='custom'`, and `corpus_array=my_variable_holding_the_documents`.

### Advanced Usage
1. `nlp_classifier.train(verbose=False)` to turn off print status statements while training.
1. `nlp_classifier.train(print_analytics_results=True)` to print out results of training the classifier.

Metadata

Release files for empythy 1.0.0

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

Source distribution (sdist)

Source distribution for empythy 1.0.0
File Size Uploaded Provenance
empythy-1.0.0.tar.gz 1.6 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for empythy 1.0.0
File Interpreter ABI Platform
empythy-1.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 3.2 MB

Release files / empythy-1.0.0.tar.gz

Download URL empythy-1.0.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
9e14a61019264ea2b5e3a8707a0e08b24178e67c89f981c6f26a9677a199547a
BLAKE2b-256 checksum
How to use checksums
2c6cd29c7026e45827fff39a1bc3726ff35521e760d2663daf0c33535e5ad169
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / empythy-1.0.0-py2.py3-none-any.whl

Download URL empythy-1.0.0-py2.py3-none-any.whl
Size 1.6 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a98d9ebd00ab2a605f42b20a2c777e3b1e84af831239bb04467a80bf3c7c21d6
BLAKE2b-256 checksum
How to use checksums
50eee771b8a40f56301403640919db735dc1f3630dd30e901bf68dc27bd062e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for empythy 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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