当前位置: 首页>>代码示例>>Python>>正文


Python StringVariable.new_meta_id方法代码示例

本文整理汇总了Python中Orange.data.StringVariable.new_meta_id方法的典型用法代码示例。如果您正苦于以下问题:Python StringVariable.new_meta_id方法的具体用法?Python StringVariable.new_meta_id怎么用?Python StringVariable.new_meta_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Orange.data.StringVariable的用法示例。


在下文中一共展示了StringVariable.new_meta_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_domain

# 需要导入模块: from Orange.data import StringVariable [as 别名]
# 或者: from Orange.data.StringVariable import new_meta_id [as 别名]
def create_domain(at, cl, metas):
    if OR3:
        return Orange.data.Domain(at, cl, metas=metas)
    else:
        domain  = Orange.data.Domain(at, cl)
        if metas:
            if isinstance(metas, dict):
                metas = sorted(metas.items())
            else:
                metas = zip([ StringVariable.new_meta_id() for _ in metas ], metas)
            domain.add_metas(dict((StringVariable.new_meta_id(), ma) for mi, ma in metas))
        return domain
开发者ID:astaric,项目名称:orange-bio,代码行数:14,代码来源:compat.py

示例2: create_domain

# 需要导入模块: from Orange.data import StringVariable [as 别名]
# 或者: from Orange.data.StringVariable import new_meta_id [as 别名]
def create_domain(at, cl, metas):
    if OR3:
        return Orange.data.Domain(at, cl, metas=metas)
    else:
        domain  = Orange.data.Domain(at, cl)
        if metas:
            domain.add_metas(dict((StringVariable.new_meta_id(), ma) for ma in  metas))
        return domain
开发者ID:acopar,项目名称:orange-bio,代码行数:10,代码来源:geo.py

示例3: create_domain

# 需要导入模块: from Orange.data import StringVariable [as 别名]
# 或者: from Orange.data.StringVariable import new_meta_id [as 别名]
def create_domain(at, cl, metas):
    if OR3:
        return Orange.data.Domain(at, cl, metas=metas)
    else:
        domain  = Orange.data.Domain(at, cl)
        if metas:
            # add metas in the reverse order (because meta ids are always decreasing)
            # this allows us to pass metas in the same order to create_table
            metas = zip([ StringVariable.new_meta_id() for _ in metas ], reversed(metas))
            domain.add_metas(dict(metas))
        return domain
开发者ID:JakaKokosar,项目名称:orange-bio,代码行数:13,代码来源:compat.py

示例4: transpose_labels_to_class

# 需要导入模块: from Orange.data import StringVariable [as 别名]
# 或者: from Orange.data.StringVariable import new_meta_id [as 别名]
def transpose_labels_to_class(data, class_label=None, gene_label="gene"):
    """Converts data with genes in rows to data with genes as attributes."""
    # if no class_label (attribute type) given, guess it from the data
    if not class_label:
        l = []
        for a in data.domain.attributes:
            l.extend(list(a.attributes.keys()))
        l = list(set(l))
        class_label = l[0]
        if len(set(l)) > 1:
            import warnings
            warnings.warn("More than single attribute label types (%s), took %s"
                          % (", ".join(l), class_label))

    if gene_label in [v.name for v in data.domain.getmetas().values()]:
        atts = [ContinuousVariable(str(d[gene_label])) for d in data]
    else:
        atts = [ContinuousVariable("A%d" % i) for i in range(len(data))]
        
    classvalues = list(set([a.attributes[class_label] for a in data.domain.attributes]))
    
    if all([isinstance(x, (int, float, complex)) for x in classvalues]):
        classvar = ContinuousVariable(class_label)
    else:
        classvar = DiscreteVariable(class_label, values=classvalues)
        
    domain = Orange.data.Domain(atts, classvar)
    
    newdata = []
    for a in data.domain.attributes:
        newdata.append([_float_or_na(d[a]) for d in data] + [a.attributes[class_label]])

    sample = StringVariable("sample")
    id = StringVariable.new_meta_id()
    new = Orange.data.Table(domain, newdata)
    new.domain.addmeta(id, sample)
    for i, d in enumerate(new):
        d[sample] = data.domain.attributes[i].name

    return new
开发者ID:acopar,项目名称:orange-bio,代码行数:42,代码来源:geo.py

示例5: transpose_class_to_labels

# 需要导入模块: from Orange.data import StringVariable [as 别名]
# 或者: from Orange.data.StringVariable import new_meta_id [as 别名]
def transpose_class_to_labels(data, attcol="sample"):
    """Converts data with genes as attributes to data with genes in rows."""
    if attcol in [v.name for v in data.domain.getmetas().values()]:
        atts = [ContinuousVariable(str(d[attcol])) for d in data]
    else:
        atts = [ContinuousVariable("S%d" % i) for i in range(len(data))]
    for i, d in enumerate(data):
        atts[i].setattr("class", str(d.getclass()))
    domain = Orange.data.Domain(atts, None)
    
    newdata = []
    for a in data.domain.attributes:
        newdata.append([_float_or_na(d[a]) for d in data])

    gene = StringVariable("gene")
    id = StringVariable.new_meta_id()
    new = Orange.data.Table(domain, newdata)
    new.domain.addmeta(id, gene)
    for i, d in enumerate(new):
        d[gene] = data.domain.attributes[i].name

    return new
开发者ID:acopar,项目名称:orange-bio,代码行数:24,代码来源:geo.py


注:本文中的Orange.data.StringVariable.new_meta_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。