# How to Define a New Model Structure The structure of the Bayesian Network in ConversionFlow is defined in the `assets/config.yml` file. This guide explains how to customize this structure to create your own models. ## Understanding the Model Structure The model is defined by two key components: - **Nodes**: These represent the stages or touchpoints in your customer journey. - **Edges**: These represent the causal relationships or transitions between the nodes. ## Steps to Define a New Model ### 1. Name Your Model First, give your new model a unique name in the `model.name` field of the `config.yml` file. ```yaml model: name: my_new_model_v1 ``` ### 2. Define the Nodes The nodes are organized into groups that correspond to the stages of the customer journey. You can add, remove, or rename these groups and the nodes within them. ```yaml nodes: start: - session_start engagement: - feature_engagement - video_view conversion: - add_to_cart - purchase ``` ### 3. Define the Edges The edges define the structure of your Bayesian Network. Each edge is a list of two nodes, representing a directed link from the first node (parent) to the second node (child). ```yaml edges: - [session_start, feature_engagement] - [session_start, video_view] - [feature_engagement, add_to_cart] - [video_view, add_to_cart] - [add_to_cart, purchase] ``` ### 4. Define the Priors For each new edge you create, you need to define a prior distribution for its `beta` coefficient. This is done in the `priors.beta_distributions` section. ```yaml priors: beta_distributions: session_start: feature_engagement: { distribution: HalfCauchy, sigma: 5 } video_view: { distribution: HalfCauchy, sigma: 5 } feature_engagement: add_to_cart: { distribution: Normal, mu: 0, sigma: 2.5 } video_view: add_to_cart: { distribution: Normal, mu: 0, sigma: 2.5 } add_to_cart: purchase: { distribution: HalfCauchy, sigma: 10 } ``` - **Parent Node Name**: The top-level key (e.g., `session_start`) is the parent node. - **Child Node Name**: The nested key (e.g., `feature_engagement`) is the child node. - **Distribution**: You can specify any PyMC distribution (e.g., `Normal`, `HalfCauchy`, `StudentT`) and its parameters. ### 5. Run the Pipeline Once you have saved your new configuration, you can run the pipeline as usual. The `BayesianNetworkModel` class will automatically build the new model structure based on your definitions. ```bash python src/orchestration/run_pipeline.py --config assets/config.yml --data your_data.db --output output_new_model ``` By following these steps, you can create custom Bayesian Network models to analyze any conversion funnel.