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


Python data.ContinuousVariable类代码示例

本文整理汇总了Python中Orange.data.ContinuousVariable的典型用法代码示例。如果您正苦于以下问题:Python ContinuousVariable类的具体用法?Python ContinuousVariable怎么用?Python ContinuousVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_invalid_input_colors

    def test_invalid_input_colors(self):
        a = ContinuousVariable("a")
        a.attributes["colors"] = "invalid"
        _ = a.colors
        t = Table(Domain([a]))

        self.send_signal(self.widget.Inputs.data, t)
开发者ID:PrimozGodec,项目名称:orange3,代码行数:7,代码来源:test_owcolor.py

示例2: test_make

 def test_make(self):
     ContinuousVariable._clear_cache()
     age1 = ContinuousVariable.make("age")
     age2 = ContinuousVariable.make("age")
     age3 = ContinuousVariable("age")
     self.assertEqual(age1, age2)
     self.assertNotEqual(age1, age3)
开发者ID:acopar,项目名称:orange3,代码行数:7,代码来源:test_variable.py

示例3: freeviz_variable

 def freeviz_variable(i):
     v = ContinuousVariable(
         "FreeViz Component {}".format(i + 1),
         compute_value=FreeVizProjector(self, i, freeviz_transform))
     v.to_sql = LinearCombinationSql(
         domain.attributes, self.components_[i, :],
         getattr(self, 'mean_', None))
     return v
开发者ID:astaric,项目名称:orange3,代码行数:8,代码来源:freeviz.py

示例4: test_make_proxy_cont

 def test_make_proxy_cont(self):
     abc = ContinuousVariable("abc")
     abc1 = abc.make_proxy()
     abc2 = abc1.make_proxy()
     self.assertIs(abc.master, abc)
     self.assertIs(abc1.master, abc)
     self.assertIs(abc2.master, abc)
     self.assertEqual(abc, abc1)
     self.assertEqual(abc, abc2)
     self.assertEqual(abc1, abc2)
开发者ID:MPOWER4RU,项目名称:orange3,代码行数:10,代码来源:test_variable.py

示例5: test_to_val

    def test_to_val(self):
        string_var = StringVariable("x")
        self.assertEqual(string_var.to_val("foo"), "foo")
        self.assertEqual(string_var.to_val(42), "42")

        cont_var = ContinuousVariable("x")
        self.assertTrue(math.isnan(cont_var.to_val("?")))
        self.assertTrue(math.isnan(Unknown))

        var = Variable("x")
        self.assertEqual(var.to_val("x"), "x")
开发者ID:acopar,项目名称:orange3,代码行数:11,代码来源:test_variable.py

示例6: test_colors

    def test_colors(self):
        a = ContinuousVariable("a")
        self.assertEqual(a.colors, ((0, 0, 255), (255, 255, 0), False))
        self.assertIs(a.colors, a._colors)

        a = ContinuousVariable("a")
        a.attributes["colors"] = ['#010203', '#040506', True]
        self.assertEqual(a.colors, ((1, 2, 3), (4, 5, 6), True))

        a.colors = ((3, 2, 1), (6, 5, 4), True)
        self.assertEqual(a.colors, ((3, 2, 1), (6, 5, 4), True))
开发者ID:acopar,项目名称:orange3,代码行数:11,代码来源:test_variable.py

示例7: test_copy_descriptor_continuous

    def test_copy_descriptor_continuous(self):
        var = ContinuousVariable("foo", number_of_decimals=42)
        var.attributes = {"bar": 42, "baz": 13}
        copied = copy_descriptor(var)
        self.assertIsInstance(copied, ContinuousVariable)
        self.assertEqual(copied.name, "foo")
        self.assertEqual(copied.number_of_decimals, 42)
        self.assertEqual(copied.attributes, var.attributes)
        self.assertIsNot(copied.attributes, var.attributes)

        var = ContinuousVariable("foo", number_of_decimals=42)
        copied = copy_descriptor(var, "cux")
        self.assertEqual(copied.name, "cux")
开发者ID:biolab,项目名称:orange3,代码行数:13,代码来源:test_owvenndiagram.py

示例8: transform_continuous

 def transform_continuous(var):
     if not self.normalize_continuous:
         return var
     new_var = ContinuousVariable(var.name)
     dma, dmi = dists[var_ptr].max(), dists[var_ptr].min()
     diff = dma - dmi
     if diff < 1e-15:
         diff = 1
     if self.zero_based:
         new_var.get_value_from = Normalizer(var, dmi, 1 / diff)
     else:
         new_var.get_value_from = Normalizer(var, (dma + dmi) / 2,
                                             2 / diff)
     return new_var
开发者ID:agiz,项目名称:orange3,代码行数:14,代码来源:continuizer.py

示例9: test_proxy_has_separate_colors

    def test_proxy_has_separate_colors(self):
        abc = ContinuousVariable("abc")
        abc1 = abc.make_proxy()
        abc2 = abc1.make_proxy()

        original_colors = abc.colors
        red_to_green = (255, 0, 0), (0, 255, 0), False
        blue_to_red = (0, 0, 255), (255, 0, 0), False

        abc1.colors = red_to_green
        abc2.colors = blue_to_red
        self.assertEqual(abc.colors, original_colors)
        self.assertEqual(abc1.colors, red_to_green)
        self.assertEqual(abc2.colors, blue_to_red)
开发者ID:acopar,项目名称:orange3,代码行数:14,代码来源:test_variable.py

示例10: test_construct_numeric_names

 def test_construct_numeric_names(self):
     data = Table("iris")
     data.domain.attributes[0].name = "0.1"
     data.domain.attributes[1].name = "1"
     desc = PyListModel(
         [ContinuousDescriptor(name="S",
                               expression="_0_1 + _1",
                               number_of_decimals=3)]
     )
     nv = construct_variables(desc, data.domain.variables)
     ndata = Table(Domain(nv, None), data)
     np.testing.assert_array_equal(ndata.X[:, 0],
                                   data.X[:, :2].sum(axis=1))
     ContinuousVariable._clear_all_caches()
开发者ID:kernc,项目名称:orange3,代码行数:14,代码来源:test_owfeatureconstructor.py

示例11: extend_attributes

    def extend_attributes(self, X, feature_names, var_attrs=None):
        """
        Append features to corpus.

        Args:
            X (numpy.ndarray): Features to append
            feature_names (list): List of string containing feature names
            var_attrs (dict): Additional attributes appended to variable.attributes.
        """
        self.X = np.hstack((self.X, X))

        new_attr = self.domain.attributes

        for f in feature_names:
            var = ContinuousVariable.make(f)
            if isinstance(var_attrs, dict):
                var.attributes.update(var_attrs)
            new_attr += (var, )

        new_domain = Domain(
                attributes=new_attr,
                class_vars=self.domain.class_vars,
                metas=self.domain.metas
        )
        self.domain = new_domain
开发者ID:david-novak,项目名称:orange3-text,代码行数:25,代码来源:corpus.py

示例12: concatenate_data

def concatenate_data(tables, filenames, label):
    domain, xs = domain_union_for_spectra(tables)
    ntables = [(table if isinstance(table, Table) else table[2]).transform(domain)
               for table in tables]
    data = type(ntables[0]).concatenate(ntables, axis=0)
    source_var = StringVariable.make("Filename")
    label_var = StringVariable.make("Label")

    # add other variables
    xs_atts = tuple([ContinuousVariable.make("%f" % f) for f in xs])
    domain = Domain(xs_atts + domain.attributes, domain.class_vars,
                    domain.metas + (source_var, label_var))
    data = data.transform(domain)

    # fill in spectral data
    xs_sind = np.argsort(xs)
    xs_sorted = xs[xs_sind]
    pos = 0
    for table in tables:
        t = table if isinstance(table, Table) else table[2]
        if not isinstance(table, Table):
            indices = xs_sind[np.searchsorted(xs_sorted, table[0])]
            data.X[pos:pos+len(t), indices] = table[1]
        pos += len(t)

    data[:, source_var] = np.array(list(
        chain(*(repeat(fn, len(table))
                for fn, table in zip(filenames, ntables)))
    )).reshape(-1, 1)
    data[:, label_var] = np.array(list(
        chain(*(repeat(label, len(table))
                for fn, table in zip(filenames, ntables)))
    )).reshape(-1, 1)
    return data
开发者ID:stuart-cls,项目名称:orange-infrared,代码行数:34,代码来源:owmultifile.py

示例13: single_x_reader

 def single_x_reader(self, spc_file):
     domvals = spc_file.x  # first column is attribute name
     domain = Domain([ContinuousVariable.make("%f" % f) for f in domvals], None)
     y_data = [sub.y for sub in spc_file.sub]
     y_data = np.array(y_data)
     table = Orange.data.Table.from_numpy(domain, y_data.astype(float, order='C'))
     return table
开发者ID:stuart-cls,项目名称:orange-infrared,代码行数:7,代码来源:data.py

示例14: read

 def read(self):
     with open(self.filename, "rb") as f:
         # read first row separately because of two empty columns
         header = f.readline().decode("ascii").rstrip().split("\t")
         header = [a.strip() for a in header]
         assert header[0] == header[1] == ""
         dom_vals = [float(v) for v in header[2:]]
         domain = Orange.data.Domain([ContinuousVariable.make("%f" % f) for f in dom_vals], None)
         tbl = np.loadtxt(f, ndmin=2)
         data = Orange.data.Table(domain, tbl[:, 2:])
         metas = [ContinuousVariable.make('map_x'), ContinuousVariable.make('map_y')]
         domain = Orange.data.Domain(domain.attributes, None, metas=metas)
         data = data.transform(domain)
         data[:, metas[0]] = tbl[:, 0].reshape(-1, 1)
         data[:, metas[1]] = tbl[:, 1].reshape(-1, 1)
         return data
开发者ID:stuart-cls,项目名称:orange-infrared,代码行数:16,代码来源:data.py

示例15: test_decimals

 def test_decimals(self):
     a = ContinuousVariable("a", 4)
     self.assertEqual(a.str_val(4.654321), "4.6543")
     self.assertEqual(a.str_val(4.654321654321), "4.6543")
     self.assertEqual(a.str_val(Unknown), "?")
     a = ContinuousVariable("a", 5)
     self.assertEqual(a.str_val(0.000000000001), "0.00000")
     a = ContinuousVariable("a", 10)
     self.assertEqual(a.str_val(0.000000000001), "1e-12")
开发者ID:PrimozGodec,项目名称:orange3,代码行数:9,代码来源:test_variable.py


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