當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。