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

Code 1.2 pz.BetaBinomial: AttributeError: module 'preliz' has no attribute 'BetaBinomial' #24

Closed
bwcastillo opened this issue May 24, 2024 · 6 comments

Comments

@bwcastillo
Copy link

Hi @aloctavodia,

I am writing because I got a problem in the Code 1.2. I installed it with pip install preliz==0.0.2. However, when I code ´pz.BetaBinomial(alpha=10, beta=10, n=6).plot_interactive()´ I got: AttributeError: module 'preliz' has no attribute 'BetaBinomial'. Do you suggest some way to solve it? I keep attentive.

Best regards from Chile.
Thanks in advance for sharing your knowledge.
Bryan

PS: Let me know if I can write you in Spanish.

@aloctavodia
Copy link
Owner

aloctavodia commented May 24, 2024 via email

@bwcastillo
Copy link
Author

bwcastillo commented May 25, 2024

Genial!

Ahora funcionó, sin embargo, obtuve:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[26], line 1
----> 1 pz.BetaBinomial(alpha=10, beta=10, n=5).plot_interactive()

File [~\.conda\envs\pymc_env\Lib\site-packages\preliz\distributions\distributions.py:541](http://localhost:8888/lab/tree/~/.conda/envs/pymc_env/Lib/site-packages/preliz/distributions/distributions.py#line=540), in Distribution.plot_interactive(self, kind, xy_lim, pointinterval, interval, levels, figsize)
    539 else:
    540     for name, value, support in zip(self.param_names, self.params, self.params_support):
--> 541         sliders[name] = get_slider(name, value, *support)
    543 def plot(**args):  # pylint: disable=inconsistent-return-statements
    544     if self.__class__.__name__ == "Categorical":

File [~\.conda\envs\pymc_env\Lib\site-packages\preliz\internal\plot_helper.py:283](http://localhost:8888/lab/tree/~/.conda/envs/pymc_env/Lib/site-packages/preliz/internal/plot_helper.py#line=282), in get_slider(name, value, lower, upper)
    280 min_v, max_v, step = generate_range(value, lower, upper)
    282 if isinstance(value, float):
--> 283     slider_type = FloatSlider
    284 else:
    285     slider_type = IntSlider

NameError: name 'FloatSlider' is not defined

De todas maneras las otras funciones trabajan.

Quedo atento.
Gracias por la inmediatez de la primera respuesta.

@aloctavodia
Copy link
Owner

Otro detalle, en las versiones nuevas de PreliZ algunas dependencias son opcionales. Podes instalarlas todas haciendo pip install "preliz[full,notebook]"

@bwcastillo
Copy link
Author

Genial funcionó perfecto.
Muchas gracias!

Quería agregar esta pregunta, no sé si tengo que abrir un nuevo issue. Entiendo que la primera parte del libro es para desarrollar las intuiciones de los tipos de distribuciones. Sin embargo, en el Código 1.4 obtuve este gráfico, que discrepa del que está en la Figura 1.4. Creo que es por la escala de .rvs(1000). Intenté con valores más bajos pero me reduce las barras a una, aunque se aprecia mejor la distribución pdf beta binomial como línea.

plt.hist(pz.BetaBinomial(alpha=2, beta=5, n=5).rvs(1000))
pz.BetaBinomial(alpha=2, beta=5, n=5).plot_pdf();

image

@aloctavodia
Copy link
Owner

En general es mejor abrir un issue por cada tema.

La diferencia entre las barras y los puntos es que el histograma no está normalizado, para que esté normalizado tenés que pasar el argumento density=True a plt.hist

@bwcastillo
Copy link
Author

Muchas gracias Osvaldo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants