Skip to main content

Library to compute the best path through a trellis graph using the Viterbi algorithm.

The source for this project is available here.


This library provides the class ViterbiTrellis. At present it can only do one thing: compute the best path through a trellis graph. The user must provide three inputs:

  1. Trellis layer structure, specified as a list of lists. Each inner list corresponds to a single layer of the trellis. The first item in the outer list is the start layer, while the final item is the end layer. Each innermost item is an object representing the state. This could be a primitive type such as an int, or it could be a tuple or user-defined class.

  2. A cost function giving the cost for being in a given state.

  3. A transition function giving the cost of transitioning between two particular states.

The best path is chosen by globally minimizing the sum of the state costs and transitions via the Viterbi algorithm.

Example usage:

from viterbi_trellis import ViterbiTrellis
v = ViterbiTrellis([[2, 6, 4], [4, 6], [0, 2, 6]], lambda x: x / 2.0, lambda x, y: abs(y - x))
best_path = v.viterbi_best_path()

The return value in best_path is a list of indices of the states in the best path:

>>> best_path
[2, 0, 1]

This result corresponds to the states labeled [4, 4, 2] in the input trellis.

Metadata

Release files for viterbi-trellis 0.0.3

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

Source distribution (sdist)

Source distribution for viterbi-trellis 0.0.3
File Size Uploaded
viterbi_trellis-0.0.3.tar.gz 5.9 kB Details

Built distribution (wheel)

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

Total release size: 13.0 kB

Release files / viterbi_trellis-0.0.3.tar.gz

Download URL viterbi_trellis-0.0.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
93ec0be923da7143a73c186e3b5322980b131ba209f666679ae8718f1f7e1bf6
BLAKE2b-256 checksum
How to use checksums
0305ad07dce92829f59a695f9c2b3474fdbb8e5032f183c81ca7f078a801c6fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / viterbi_trellis-0.0.3-py2.py3-none-any.whl

Download URL viterbi_trellis-0.0.3-py2.py3-none-any.whl
Size 7.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
76417a1c6c032392f91ee816be31202087954834006a5758f4244ffdefa92b71
BLAKE2b-256 checksum
How to use checksums
9bd9ebcecf39ea01767aa9eb1a268acd5d2eeaf55a6039f24257ba5e14ad5a52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

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