Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summarize model as rich table #382

Merged
merged 3 commits into from
Oct 20, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Oct 14, 2024

From pymc-devs/pymc#7210 (comment)

import numpy as np
import pymc as pm

from pymc_experimental.printing import model_table

coords = {"subject": range(20), "param": ["a", "b"]}
with pm.Model(coords=coords) as m:
    x = pm.Data("x", np.random.normal(size=(20, 2)), dims=("subject", "param"))
    y = pm.Data("y", np.random.normal(size=(20,)), dims="subject")

    beta = pm.Normal("beta", mu=0, sigma=1, dims="param")
    mu = pm.Deterministic("mu", pm.math.dot(x, beta), dims="subject")
    sigma = pm.HalfNormal("sigma", sigma=1)

    y_obs = pm.Normal("y_obs", mu=mu, sigma=sigma, observed=y, dims="subject")

model_table(m)
 Variable  Expression         Dimensions             
─────────────────────────────────────────────────────
      x =  Data               subject[20] × param[2] 
      y =  Data               subject[20]            
                                                     
   beta ~  Normal(0, 1)       param[2]               
  sigma ~  HalfNormal(0, 1)                          
                              Parameter count = 3    
                                                     
     mu =  f(beta)            subject[20]            
                                                     
  y_obs ~  Normal(mu, sigma)  subject[20]     

@ricardoV94 ricardoV94 added the enhancements New feature or request label Oct 14, 2024
@ricardoV94 ricardoV94 changed the title Summarize model with rich table Summarize model as rich table Oct 14, 2024
@ricardoV94 ricardoV94 added the docs Improvements or additions to documentation label Oct 14, 2024
@ricardoV94
Copy link
Member Author

@ricardoV94 ricardoV94 merged commit c0dac7f into pymc-devs:main Oct 20, 2024
7 checks passed
@ricardoV94 ricardoV94 deleted the print_model_table branch October 20, 2024 07:21
@ricardoV94 ricardoV94 restored the print_model_table branch October 20, 2024 07:21
@ricardoV94 ricardoV94 deleted the print_model_table branch October 20, 2024 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation enhancements New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants