双集群编辑库
biclustp的Python项目详细描述
双色
用于双集群编辑的python库。
双群集编辑问题
- 任务:给定一个带正负权重的矩阵
weights
,通过边插入和删除将由weights
诱导的二部图转换为不相交的两个团(双簇)集合,这样总体转换成本最小。 - 由
weights
引起的二部图的节点集是行和列的集合。当且仅当weights[i,k] > 0
时,行i
和列k
之间有一条边。
安装
库使用
安装后,import biclustpy as bp
进入python应用程序。然后按如下方式使用:
bp.Algorithm
:使用此类选择要使用的算法。bp.Algorithm.algorithm_name
:可以用来选择要采用的算法的字符串。默认值:"ILP"
。- 如果要使用gurobi来解决G. F. de Sousa Filho et al (2017): New heuristics for the bicluster editing problem中建议的ilp公式,请设置为
"ILP"
。 - 如果要使用G. F. de Sousa Filho et al (2017): New heuristics for the bicluster editing problem中建议的构造性启发式,请设置为
"CH"
。 - 很快就会有更多的算法出现。
- 如果要使用gurobi来解决G. F. de Sousa Filho et al (2017): New heuristics for the bicluster editing problem中建议的ilp公式,请设置为
bp.Algorithm.ilp_time_limit
:整数,指定算法优化和优化阶段的时间限制(秒)。默认值:60
。bp.Algorithm.ilp_tune
:布尔标志,指示在优化前是否应调整"ILP"
。默认值:False
。
bp.compute_bi_clusters(weights, algorithm)
:使用此函数可解决双群集编辑问题。weights
:作为numpy.array
给定的问题实例。algorithm
:指定为bp.Algorithm
对象的选定算法。
bp.save_bi_clusters_as_xml(filename, bi_clusters, obj_val, is_optimal, instance = "")
:使用此函数将获得的解决方案保存为XML文件。filename
:XML文件的名称。bi_clusters
:由bp.compute_bi_clusters
返回的bi集群。obj_val
:由bp.compute_bi_clusters
返回的bi集群的目标值。is_optimal
:由bp.compute_bi_clusters
返回的标志,指示计算出的bi集群是否保证是最优的。instance
:包含问题实例信息的字符串。
示例
import numpy as np
import biclustpy as bp
algorithm = bp.Algorithm
algorithm.algorith_name = "ILP"
algorithm.ilp_time_limit = 100
algorithm.ilp_tune = True
n = 30
m = 40
t = .95
weights = np.random.rand(n, m) - (t * np.ones((n, m)))
bi_clusters, obj_val, is_optimal = bp.compute_bi_clusters(weights, algorithm)
filename = "bi_clusters.xml"
instance = "random instance with 30 rows and 40 columns"
bp.save_bi_clusters_as_xml(filename, bi_clusters, obj_val, is_optimal, instance)
命令行用法
安装后,可以从命令行运行biclustpy
。用法:
biclustpy [-h]
(--load input-file | --random num-rows num-cols threshold seed)
[--save output-file] [--alg {ILP,CH}]
[--ilp_options time-limit tune]
更多信息,请执行biclustpy -h
。
许可证
您可以根据GNU Lesser General Public License的条款使用和分发biclustpy。