贝叶斯割方法的一种实现

bayesian-cut的Python项目详细描述


Pypi VersionLicenseBuild Status

bayesian cut python包为bayesian网络的直接应用提供了一个易于使用的api 基于gibbs抽样的度修正随机全贝叶斯推理框架的割集 块模型(dc-sbm)或贝叶斯割(bc)。 此外,还提供了基于模块化、比率切割和范数切割的谱网络切割方法。 它还提供了一个丰富的可视化库,可以方便地分析后验解决方案景观和网络 通过各种方法得到的切割。

Jupyter笔记本电脑上有如何使用该软件包的示例,请访问 https://github.com/DTUComputeCognitiveSystems/bayesian_cut/tree/master/examples

安装

  • 使用以下命令安装python3的包。一些 依赖项可能需要升级(scikit learn、numpy和 scipy)。
    $ pip install bayesian_cut
  • 现在您可以通过键入
    from bayesian_cut.cuts import Model

快速启动

使用bayesian_-cut包执行图切割

# Load the packagefrombayesian_cut.data.loadimportload_datafrombayesian_cut.cuts.bayesian_modelsimportModel# Load an example networknetwork_name='karate'X,Y=load_data(network=network_name,labels=True,remove_disconnected=True)# Set the parameters for the modeln_samples_per_chain=75n_chains=15C=2model_params={'alpha_in':1e-2,'beta_in':1e-2,'alpha_out':1e-2,'beta_out':1e-2,'b':1,'gamma':3}# Define the modelBC=Model('ShiftedApproximateBayesianCommunityDetection',X,model_params,Y=Y,C=C,block_sampling=False,marginalize_phi=True)# Add the number of chains to runBC.add_chains(number_of_chains=n_chains)# Run the Gibbs samplerBC.run_chains(n_samples=n_samples_per_chain,n_prior_updates=20,verbose=2,save_all_samples=False,parallel=True)# Obtain the cut with the highest log-likelihoodgraph_cut_z_vector=BC.get_best_chain().max_log_lik_z_# Plot the cut as an adjacency matrixfrombayesian_cut.utilsimportutilsutils.cluster_plot(BC)# Done

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Kotlin应该为Java类中的合成属性进行反射   hadoop。pig脚本与java嵌入式pig:哪一个最快?   java要求用户在不关闭程序的情况下输入一个double而不是字符串   Raspberry PI和windows pc代码之间的java差异   使用maven的基于java Spring引导概要文件的WAR   Java中的内联数组定义   jsf如何在Tomcat上安装和使用CDI?   当数据来自mySQL时,在java的微调器中删除重复项   java如何定制Android ListView的每一行?   对于web应用程序,为什么java也被称为平台无关?   java如何获得排序hashmap中两个给定键之间的所有键值?   帮我把这个Java翻译成Scheme,让我脑子里的东西运转起来   java共享子域cookie   hibernate多Java列表删除   java队列可以用来交换链表的相邻节点吗?   java遇到错误:当我在安卓应用程序中单击主屏幕快捷方式时,找不到应用程序