Neural Network to classify short strings
Project description
Char Classifier
---------
Given a short phrase, train a neural network to classify it based on the characters that it contains.
The trainer takes in a file of phrases (separated by new line) and a file of target values (separated by new line).
To train on the sample data (parts of speech classification):
```
import chClassifier
p = chClassifier.Trainer("sample/words", "sample/parts-of-speech")
p.train([100, 100], 20, 100)
p.save("sample", "example-run")
```
This will save a trained model with the tag 'example-run' in the sample directory. To use that model, run:
```
import chClassifier
k = chClassifier.Classifier("sample", "example-run")
print k.classify("dog")
```
This will return an array of tuples of original label + likelyhood that the label is correct, like so:
```
>> print k.classify("dog")
[(u'VB', 0.050349433), (u'NN', 3.8027303)]
```
The higher the number, the more sure we are of the classification (`dog` is definitely a noun, for example, and probably not a verb).
---------
Given a short phrase, train a neural network to classify it based on the characters that it contains.
The trainer takes in a file of phrases (separated by new line) and a file of target values (separated by new line).
To train on the sample data (parts of speech classification):
```
import chClassifier
p = chClassifier.Trainer("sample/words", "sample/parts-of-speech")
p.train([100, 100], 20, 100)
p.save("sample", "example-run")
```
This will save a trained model with the tag 'example-run' in the sample directory. To use that model, run:
```
import chClassifier
k = chClassifier.Classifier("sample", "example-run")
print k.classify("dog")
```
This will return an array of tuples of original label + likelyhood that the label is correct, like so:
```
>> print k.classify("dog")
[(u'VB', 0.050349433), (u'NN', 3.8027303)]
```
The higher the number, the more sure we are of the classification (`dog` is definitely a noun, for example, and probably not a verb).
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
chClassifier-0.6.4.tar.gz
(5.8 kB
view details)
Built Distribution
File details
Details for the file chClassifier-0.6.4.tar.gz
.
File metadata
- Download URL: chClassifier-0.6.4.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 879448bd980b03d10593f425c9f900fcb2e8f8d2962798fbed6023dff78634f2 |
|
MD5 | 4779292e9a59a665985ccf1adb38f66d |
|
BLAKE2b-256 | 47b25935b2c7f6fef597b3ab9c1c61a97195195017db9d60cd214d14f1d0bc57 |
File details
Details for the file chClassifier-0.6.4-py2.py3-none-any.whl
.
File metadata
- Download URL: chClassifier-0.6.4-py2.py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc2e34ab2c9f45e9132fde47ea1f8028085fe5e1e9b0b53640c5a2d226fedb21 |
|
MD5 | 66f2c7b564bf9f7d260295312ec5fce6 |
|
BLAKE2b-256 | 2202eca7b122ffdf078e4bf47302b0e20a14ea2f8e5939e0a39ca2a940d9d7d5 |