wbn package

Submodules

wbn.classifier module

Weighted Bayesian Network Text Classification Model.

class wbn.classifier.WBN(depth: float = 0.05)[source]

Bases: object

Weighted Bayesian Network Classifier.

fit(data: List[wbn.object.DocumentData], target: List[str]) → List[wbn.object.Classification][source]

Builds directed acyclic graphs and corpora for class traversal and classification.

dataList[DocumentData]

Array of annotated keywords

targetList[str]

Array of target classifications

List[Classification]

Array of dag & corpus classifications

predict(data: List[wbn.object.DocumentData]) → List[int][source]

Predict class of for keywords in ‘data’.

dataList[DocumentData]

Array of cleaned words from input.

List[int]

Array of instance class predictions

reverse_encode(target: List[int]) → List[str][source]

Reverse encodes int targets/predictions for metrics.

targetList[int]

Array of encoded targets/predictions

List[str]

Reverse encoded array of targets/predictions

wbn.config module

Configurations and Constants.

wbn.errors module

Custom Exceptions for WBN.

exception wbn.errors.InstanceCountError(data: numpy.ndarray, target: numpy.ndarray)[source]

Bases: wbn.errors.WBNException

InstanceCountError Exception.

exception wbn.errors.MaxDepthExceededError(depth: float)[source]

Bases: wbn.errors.WBNException

MaxDepthExceededError Exception.

exception wbn.errors.WBNException[source]

Bases: Exception

Base WBN Exception.

wbn.object module

Reusable Objects for WBN.

class wbn.object.Attribute(word: str, weight: float, positive: int, negative: int)[source]

Bases: tuple

Attribute class representing Word & Weight.

property negative

Alias for field number 3

property positive

Alias for field number 2

property total

Calculates total positives and negatives.

property weight

Alias for field number 1

property word

Alias for field number 0

class wbn.object.Classification(dag: networkx.classes.digraph.DiGraph, cls: str, corpus: List[str])[source]

Bases: tuple

Classification output holding DAG and Corpus.

property cls

Alias for field number 1

property corpus

Alias for field number 2

property dag

Alias for field number 0

class wbn.object.ClassificationScore(cls: int, probability: float, edges: List[Tuple[wbn.object.Attribute, wbn.object.Attribute]])[source]

Bases: tuple

Classification score output holding class, probability and edges.

property cls

Alias for field number 0

property edges

Alias for field number 2

property probability

Alias for field number 1

class wbn.object.Document(data: wbn.object.DocumentData, target: str)[source]

Bases: tuple

Document data structure for ‘data’ and ‘target’.

property data

Alias for field number 0

property target

Alias for field number 1

class wbn.object.DocumentData(tokens: List[str], keywords: Optional[List[str]] = None)[source]

Bases: tuple

Document ‘data’ entry with paragraphs and keywords.

property keywords

Alias for field number 1

property tokens

Alias for field number 0

class wbn.object.Documents(documents: List[wbn.object.Document])[source]

Bases: list

Data structure to hold an access ‘Document’ entries.

property data

Access for ‘data’ elements.

property target

Access for ‘target’ elements.

Module contents

Top-level package for wbn.