PsieUszka

return results if name == " main ": # Load your inference data # idata = az.from_netcdf("my_model.nc")

# 4. Tree depth if hasattr(inference_data, "sample_stats") and hasattr(inference_data.sample_stats, "tree_depth"): depths = inference_data.sample_stats.tree_depth.values max_depth = np.max(depths) # depends on sampler # typical max depth is 10 at_max = (depths == max_depth).mean() if at_max > max_tree_depth_fraction: results["warnings"].append(f"Frequent max tree depth ({at_max:.2f})")

# For demo, create dummy data import pymc as pm with pm.Model(): x = pm.Normal("x") trace = pm.sample(1000, chains=2, return_inferencedata=True)

# 5. BFMI if hasattr(inference_data, "sample_stats") and hasattr(inference_data.sample_stats, "bfmi"): bfmi = inference_data.sample_stats.bfmi.values.mean() if bfmi < bfmi_threshold: results["failures"].append(f"BFMI = {bfmi:.2f} < {bfmi_threshold}") results["passed"] = False

ess_ratio = ess / total_samples if np.any(ess_ratio < ess_ratio_threshold): results["warnings"].append(f"Low ESS/total_samples (< {ess_ratio_threshold})")

# 2. ESS / total samples ess = az.ess(inference_data).to_array().values n_samples = inference_data.posterior.sizes["draw"] n_chains = inference_data.posterior.sizes["chain"] total_samples = n_samples * n_chains

report = hmc_checker(trace)

Szablon Shoper Modern 3.0™ od GrowCommerce
Sklep jest w trybie podglądu
Pokaż pełną wersję strony
Sklep internetowy Shoper.pl