def statistics_olr(self, m): if m is None: return None columns = [ variable.String("Variable"), variable.Continuous("Coeff Est"), variable.Continuous("Std Error"), variable.Continuous("t-value"), variable.Continuous("p") ] domain = Orange.data.Domain(columns, None) vars = ["Intercept"] if m.intercept else [] vars.extend([a.name for a in m.domain.attributes]) stats = [] geti = lambda list, i: list[i] if list is not None else "?" for i, var in enumerate(vars): coef = m.coefficients[i] std_err = geti(m.std_error, i) t_val = geti(m.t_scores, i) p = geti(m.p_vals, i) stats.append([var, coef, std_err, t_val, p]) return Orange.data.Table(domain, stats)
def matrix_to_table(matrix, items=None): if items is None: items = getattr(matrix, "items", None) if items is None: items = range(matrix.dim) items = map(str, items) attrs = [variable.Continuous(name) for name in items] domain = Orange.data.Domain(attrs, None) row_name = variable.String("Row name") domain.addmeta(Orange.feature.Descriptor.new_meta_id(), row_name) table = Orange.data.Table(domain, [list(r) for r in matrix]) for item, row in zip(items, table): row[row_name] = item return table
_global_id += 1 yield id def uuid_generator(): import uuid while True: yield str(uuid.uuid4()) import Orange.feature new_meta_id = Orange.feature.Descriptor.new_meta_id _row_meta_id = new_meta_id() _id_variable = variable.String("Row Id") def add_row_id(table, start=0): """ Add an Row Id meta variable to the table. Parameters ========== :param table: The ids will be added to this table. :type table: Orange.data.Table :param start: Start id for the ids. It can also be an iterator yielding unique values. :type start: int