Weighted Bayesian Network Text Classification
Project description
wbn
Weighted Bayesian Network Text Classification
Free software: MIT license
Documentation: https://wbn.readthedocs.io.
Installation
From source
$ git clone https://github.com/leonkozlowski/wbn.git
$ cd wbn
$ python3.8 -m venv venv
$ pip install -e .
Usage
Building, training, and testing WBN
from sklearn.model_selection import train_test_split
# Import WBN
from wbn.classifier import WBN
from wbn.sample.datasets import load_pr_newswire
# Build the model
wbn = WBN()
# Load a sample dataset
pr_newswire = load_pr_newswire()
# Train/test split
x_train, x_test, y_train, y_test = train_test_split(
pr_newswire.data, pr_newswire.target, test_size=0.2
)
# Fit the model
wbn.fit(x_train, y_train)
# Testing the model
pred = wbn.predict(x_test)
# Reverse encode the labels
y_pred = wbn.reverse_encode(target=pred)
Constructing a new dataset:
import pickle
# Import data structures for dataset creation
from wbn.object import Document, DocumentData, Documents
# Load your dataset from csv or pickle
with open("dataset.pickle"), "rb") as infile:
raw_data = pickle.load(infile)
# De-structure 'data' and 'target'
data = raw_data.get("data")
target = raw_data.get("target")
# Construct Document's for each data/target entry
documents = Documents(
[
Document(DocumentData(paragraphs, keywords), target[idx])
for idx, (paragraphs, keywords) in enumerate(data)
]
)
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.0 (2020-11-03)
First release on PyPI.
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
wbn-0.1.0.tar.gz
(17.1 kB
view details)
Built Distribution
File details
Details for the file wbn-0.1.0.tar.gz
.
File metadata
- Download URL: wbn-0.1.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a86a39bb50d333c51dea225bab3bedf850d23eaf4be2d8da07af2bc02711aff |
|
MD5 | 1039b3a0fa2b988b3612eb5482225d5a |
|
BLAKE2b-256 | 435c98a37ecc07e144b2b83809599fc05b7fe2dcd031bb441c7b657eae374421 |
File details
Details for the file wbn-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: wbn-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f63edc48049b974fa19faf20089b1eff3edbada098c928f1a6fa132d63df43c |
|
MD5 | 015faada78eb97a90a70ae0cf6184999 |
|
BLAKE2b-256 | 50248f0c6e3dc62f3e0c686c8b0aec3266ee1c37672963191aab3c28f86f0df1 |