Skip to main content

A path-oriented database for storing and analyzing sequential decision paths

Project description

FiberTree

FiberTree is a path-oriented database for storing and analyzing sequential decision paths. It helps you track, analyze, and optimize decision processes by recording decision paths (fibers) and their outcomes.

Core Concepts

FiberTree is built around three key concepts:

Move

Represents a single decision or action in a sequence. Can store any type of value and optional metadata.

Fiber

A container for a sequence of moves forming a decision path. Each Fiber contains move sequences and related statistics (visit count, win rate, etc.).

FiberTree

A database that manages a collection of Fibers, providing functionality for adding, querying, analyzing, and visualizing decision paths.

Installation

pip install fbtree

Basic Usage

from fbtree import create_tree, Move

# Create a tree
tree = create_tree()

# Record a decision path
tree.start_path()
tree.add_move(Move("A"))
tree.add_move(Move("B"))
tree.add_move(Move("C"))
tree.record_outcome('win')

# Get statistics
stats = tree.get_statistics()
print(f"Path statistics: {stats}")

# Find the best continuation from a specific position
best_moves = tree.get_best_continuation([Move("A")], top_n=2)
for move_info in best_moves:
    print(f"{move_info['move']} - Win rate: {move_info['win_rate']:.2f}")

# Save the tree
tree.save("my_decision_tree.json")

Advanced Features

  • Statistical Analysis: Track win rates, visit counts, and other metrics
  • Path Finding: Search for specific decision paths and find optimal continuations
  • Move Frequency Analysis: Analyze frequency of moves at specific depths
  • Path Diversity Analysis: Get insights into path distribution and branching factors
  • Heatmap Generation: Create heatmaps for board games
  • Tree Visualization: Visualize the decision tree structure as text or Graphviz diagrams
  • Tree Pruning: Remove low-value or overly deep paths
  • Tree Merging: Combine knowledge from multiple trees

Storage Options

FiberTree provides two storage backends:

Memory Storage

# Default in-memory storage
tree = create_tree()
  • Fast, suitable for temporary analysis
  • Data is lost when the program ends unless exported with save
  • Ideal for smaller datasets

SQLite Storage

# SQLite persistent storage
tree = create_tree(storage_type='sqlite', db_path='my_database.db')
  • Data persists on disk
  • Supports larger datasets
  • Suitable for long-term data collection and analysis

Use Cases

FiberTree is particularly well-suited for:

  1. Game AI Development: Store and analyze game decision trees
  2. User Behavior Analysis: Track user navigation paths in apps or websites
  3. Sequential Decision Optimization: Industrial process optimization, medical diagnosis paths
  4. Knowledge Representation: Build decision knowledge bases and capture expert decision patterns

API Reference

See the full documentation for complete API reference.

License

MIT

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

fbtree-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fbtree-0.1.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file fbtree-0.1.0.tar.gz.

File metadata

  • Download URL: fbtree-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for fbtree-0.1.0.tar.gz
Algorithm Hash digest
SHA256 add762edb4efb4a23960c0fd097c2b580b007622e3bd412cac4b0140e2248ff7
MD5 bd44dd2c6b8c7a09911b8b26e6abaa26
BLAKE2b-256 028039bc099c9c5011e5d62af9f0c7aebd3a4c19ca168e22dd02d60df318ab6c

See more details on using hashes here.

File details

Details for the file fbtree-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fbtree-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for fbtree-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c85ff5fd738f321ad8722f4d6fd7f47b8915755ad105a76cc8a0b78fe94417f3
MD5 2a00a07454343a778b16e360c5c391ad
BLAKE2b-256 b6283d05372b01a6e9245e863d7d0b4f12cf75e96690c341989aef054e60d59f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page