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


Python ContinuousVariable.make方法代码示例

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


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

示例1: test_make

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
 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,代码行数:9,代码来源:test_variable.py

示例2: concatenate_data

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
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,代码行数:36,代码来源:owmultifile.py

示例3: single_x_reader

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
 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,代码行数:9,代码来源:data.py

示例4: extend_attributes

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
    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,代码行数:27,代码来源:corpus.py

示例5: read

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
 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,代码行数:18,代码来源:data.py

示例6: _guess_variable

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
    def _guess_variable(self, field_name, field_metadata, inspect_table):
        type_code = field_metadata[0]

        FLOATISH_TYPES = (700, 701, 1700)  # real, float8, numeric
        INT_TYPES = (20, 21, 23)  # bigint, int, smallint
        CHAR_TYPES = (25, 1042, 1043,)  # text, char, varchar
        BOOLEAN_TYPES = (16,)  # bool
        DATE_TYPES = (1082, 1114, 1184, )  # date, timestamp, timestamptz
        # time, timestamp, timestamptz, timetz
        TIME_TYPES = (1083, 1114, 1184, 1266,)

        if type_code in FLOATISH_TYPES:
            return ContinuousVariable.make(field_name)

        if type_code in TIME_TYPES + DATE_TYPES:
            tv = TimeVariable.make(field_name)
            tv.have_date |= type_code in DATE_TYPES
            tv.have_time |= type_code in TIME_TYPES
            return tv

        if type_code in INT_TYPES:  # bigint, int, smallint
            if inspect_table:
                values = self.get_distinct_values(field_name, inspect_table)
                if values:
                    return DiscreteVariable.make(field_name, values)
            return ContinuousVariable.make(field_name)

        if type_code in BOOLEAN_TYPES:
            return DiscreteVariable.make(field_name, ['false', 'true'])

        if type_code in CHAR_TYPES:
            if inspect_table:
                values = self.get_distinct_values(field_name, inspect_table)
                # remove trailing spaces
                values = [v.rstrip() for v in values]
                if values:
                    return DiscreteVariable.make(field_name, values)

        return StringVariable.make(field_name)
开发者ID:thocevar,项目名称:orange3,代码行数:41,代码来源:postgres.py

示例7: construct_output_data_table

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
    def construct_output_data_table(embedded_images, embeddings):
        # X = util.hstack((embedded_images.X, embeddings))
        # embedded_images.X = X

        new_attributes = [ContinuousVariable.make('n{:d}'.format(d))
                          for d in range(embeddings.shape[1])]

        domain_new = Domain(
            list(embedded_images.domain.attributes) + new_attributes,
            embedded_images.domain.class_vars,
            embedded_images.domain.metas)
        table = embedded_images.transform(domain_new)
        table[:, new_attributes] = embeddings

        return table
开发者ID:biolab,项目名称:orange3-imageanalytics,代码行数:17,代码来源:image_embedder.py

示例8: test_domaineditor_makes_variables

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
    def test_domaineditor_makes_variables(self):
        # Variables created with domain editor should be interchangeable
        # with variables read from file.

        dat = """V0\tV1\nc\td\n\n1.0\t2"""
        v0 = StringVariable.make("V0")
        v1 = ContinuousVariable.make("V1")

        with named_file(dat, suffix=".tab") as filename:
            self.open_dataset(filename)

            model = self.widget.domain_editor.model()
            model.setData(model.createIndex(0, 1), "text", Qt.EditRole)
            model.setData(model.createIndex(1, 1), "numeric", Qt.EditRole)
            self.widget.apply_button.click()

            data = self.get_output(self.widget.Outputs.data)
            self.assertEqual(data.domain["V0"], v0)
            self.assertEqual(data.domain["V1"], v1)
开发者ID:lanzagar,项目名称:orange3,代码行数:21,代码来源:test_owfile.py

示例9: multi_x_reader

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
    def multi_x_reader(self, spc_file):
        # use x-values as domain
        all_x = []
        for sub in spc_file.sub:
            x = sub.x
            # assume values in x do not repeat
            all_x = np.union1d(all_x, x)
        domain = Domain([ContinuousVariable.make("%f" % f) for f in all_x], None)

        instances = []
        for sub in spc_file.sub:
            x, y = sub.x, sub.y
            newinstance = np.ones(len(all_x))*np.nan
            ss = np.searchsorted(all_x, x)  # find positions to set
            newinstance[ss] = y
            instances.append(newinstance)

        y_data = np.array(instances).astype(float, order='C')
        return Orange.data.Table.from_numpy(domain, y_data)
开发者ID:stuart-cls,项目名称:orange-infrared,代码行数:21,代码来源:data.py

示例10: transpose_table

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
def transpose_table(table):
    """
    Transpose the rows and columns of the table.

    Args:
        table: Data in :obj:`Orange.data.Table`

    Returns:
         Transposed :obj:`Orange.data.Table`. (Genes as columns)
    """
    attrs = table.domain.attributes
    attr = [ContinuousVariable.make(ex['Gene'].value) for ex in table]
    #  Set metas
    new_metas = [StringVariable.make(name) if name is not 'Time' else TimeVariable.make(name)
                 for name in sorted(table.domain.variables[0].attributes.keys())]
    domain = Domain(attr, metas=new_metas)
    meta_values = [[exp.attributes[var.name] for var in domain.metas] for exp in attrs]

    return Table(domain, table.X.transpose(), metas=meta_values)
开发者ID:JakaKokosar,项目名称:orange-bio,代码行数:21,代码来源:tools.py

示例11: read_spectra

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
    def read_spectra(self):
        am = agilentMosaicIFG(self.filename)
        info = am.info
        X = am.data

        features = np.arange(X.shape[-1])

        try:
            px_size = info['FPA Pixel Size'] * info['PixelAggregationSize']
        except KeyError:
            # Use pixel units if FPA Pixel Size is not known
            px_size = 1
        x_locs = np.linspace(0, X.shape[1]*px_size, num=X.shape[1], endpoint=False)
        y_locs = np.linspace(0, X.shape[0]*px_size, num=X.shape[0], endpoint=False)

        features, data, additional_table = _spectra_from_image(X, features, x_locs, y_locs)

        import_params = ['Effective Laser Wavenumber',
                         'Under Sampling Ratio',
        ]
        new_attributes = []
        new_columns = []
        for param_key in import_params:
            try:
                param = info[param_key]
            except KeyError:
                pass
            else:
                new_attributes.append(ContinuousVariable.make(param_key))
                new_columns.append(np.full((len(data),), param))

        domain = Domain(additional_table.domain.attributes,
                        additional_table.domain.class_vars,
                        additional_table.domain.metas + tuple(new_attributes))
        table = additional_table.transform(domain)
        table[:, new_attributes] = np.asarray(new_columns).T

        return (features, data, table)
开发者ID:stuart-cls,项目名称:orange-infrared,代码行数:40,代码来源:data.py

示例12: read

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]
    def read(self):
        who = matlab.whosmat(self.filename)
        if not who:
            raise IOError("Couldn't load matlab file " + self.filename)
        else:
            ml = matlab.loadmat(self.filename, chars_as_strings=True)

            ml = {a: b for a, b in ml.items() if isinstance(b, np.ndarray)}

            # X is the biggest numeric array
            numarrays = []
            for name, con in ml.items():
                 if issubclass(con.dtype.type, numbers.Number):
                    numarrays.append((name, reduce(lambda x, y: x*y, con.shape, 1)))
            X = None
            if numarrays:
                nameX = max(numarrays, key=lambda x: x[1])[0]
                X = ml.pop(nameX)

            # find an array with compatible shapes
            attributes = []
            if X is not None:
                nameattributes = None
                for name, con in ml.items():
                    if con.shape in [(X.shape[1],), (1, X.shape[1])]:
                        nameattributes = name
                        break
                attributenames = ml.pop(nameattributes).ravel() if nameattributes else range(X.shape[1])
                attributenames = [str(a).strip() for a in attributenames]  # strip because of numpy char array
                attributes = [ContinuousVariable.make(a) for a in attributenames]

            metas = []
            metaattributes = []

            sizemetas = None
            if X is None:
                counts = defaultdict(list)
                for name, con in ml.items():
                    counts[len(con)].append(name)
                if counts:
                    sizemetas = max(counts.keys(), key=lambda x: len(counts[x]))
            else:
                sizemetas = len(X)
            if sizemetas:
                for name, con in ml.items():
                    if len(con) == sizemetas:
                        metas.append(name)

            metadata = []
            for m in sorted(metas):
                f = ml[m]
                metaattributes.append(StringVariable.make(m))
                f.resize(sizemetas, 1)
                metadata.append(f)

            metadata = np.hstack(tuple(metadata))

            domain = Domain(attributes, metas=metaattributes)
            if X is None:
                X = np.zeros((sizemetas, 0))
            return Orange.data.Table.from_numpy(domain, X, Y=None, metas=metadata)
开发者ID:borondics,项目名称:orange-infrared,代码行数:63,代码来源:data.py

示例13: calculateFFT

# 需要导入模块: from Orange.data import ContinuousVariable [as 别名]
# 或者: from Orange.data.ContinuousVariable import make [as 别名]

#.........这里部分代码省略.........
                                 zff=2**self.zff,
                                 phase_res=self.phase_resolution if self.phase_res_limit else None,
                                 phase_corr=self.phase_corr,
                                 peak_search=self.peak_search,
                                )

        stored_phase = self.stored_phase
        stored_zpd_fwd, stored_zpd_back = None, None
        # Only use first row stored phase for now
        if stored_phase is not None:
            stored_phase = stored_phase[0]
            try:
                stored_zpd_fwd = int(stored_phase["zpd_fwd"].value)
            except ValueError:
                stored_zpd_fwd = None
            try:
                stored_zpd_back = int(stored_phase["zpd_back"].value)
            except ValueError:
                stored_zpd_back = None
            stored_phase = stored_phase.x # lowercase x for RowInstance

        for row in self.data.X:
            if self.sweeps in [2, 3]:
                # split double-sweep for forward/backward
                # forward: 2-2 = 0 , backward: 3-2 = 1
                try:
                    row = np.hsplit(row, 2)[self.sweeps - 2]
                except ValueError as e:
                    self.Error.ifg_split_error(e)
                    return

            if self.sweeps in [0, 2, 3]:
                try:
                    spectrum_out, phase_out, wavenumbers = fft_single(
                        row, zpd=stored_zpd_fwd, phase=stored_phase)
                    zpd_fwd.append(fft_single.zpd)
                except ValueError as e:
                    self.Error.fft_error(e)
                    return
            elif self.sweeps == 1:
                # Double sweep interferogram is split, solved independently and the
                # two results are averaged.
                try:
                    data = np.hsplit(row, 2)
                except ValueError as e:
                    self.Error.ifg_split_error(e)
                    return

                fwd = data[0]
                # Reverse backward sweep to match fwd sweep
                back = data[1][::-1]

                # Calculate spectrum for both forward and backward sweeps
                try:
                    spectrum_fwd, phase_fwd, wavenumbers = fft_single(
                        fwd, zpd=stored_zpd_fwd, phase=stored_phase)
                    zpd_fwd.append(fft_single.zpd)
                    spectrum_back, phase_back, wavenumbers = fft_single(
                        back, zpd=stored_zpd_back, phase=stored_phase)
                    zpd_back.append(fft_single.zpd)
                except ValueError as e:
                    self.Error.fft_error(e)
                    return

                # Calculate the average of the forward and backward sweeps
                spectrum_out = np.mean(np.array([spectrum_fwd, spectrum_back]), axis=0)
                phase_out = np.mean(np.array([phase_fwd, phase_back]), axis=0)
            else:
                return

            spectra.append(spectrum_out)
            phases.append(phase_out)

        spectra = np.vstack(spectra)
        phases = np.vstack(phases)

        self.phases_table = build_spec_table(wavenumbers, phases,
                                             additional_table=self.data)
        self.phases_table = add_meta_to_table(self.phases_table,
                                              ContinuousVariable.make("zpd_fwd"),
                                              zpd_fwd)
        if zpd_back:
            self.phases_table = add_meta_to_table(self.phases_table,
                                                  ContinuousVariable.make("zpd_back"),
                                                  zpd_back)

        if self.limit_output is True:
            limits = np.searchsorted(wavenumbers,
                                     [self.out_limit1, self.out_limit2])
            wavenumbers = wavenumbers[limits[0]:limits[1]]
            # Handle 1D array if necessary
            if spectra.ndim == 1:
                spectra = spectra[None, limits[0]:limits[1]]
            else:
                spectra = spectra[:, limits[0]:limits[1]]

        self.spectra_table = build_spec_table(wavenumbers, spectra,
                                              additional_table=self.data)
        self.Outputs.spectra.send(self.spectra_table)
        self.Outputs.phases.send(self.phases_table)
开发者ID:markotoplak,项目名称:orange-infrared,代码行数:104,代码来源:owfft.py


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