class ZeroBottomUp(BottomUp): def __init__(self, *args, **kwargs): self.zero = None BottomUp.__init__(self, *args, **kwargs) def setup(self, table): """ normalize the data ranges before calling parent setup with normalized table """ self.data = table.to_numpyMA('ac')[0] pred_columns = [table.domain.index(table.domain[c]) for c in self.cols] search_cols = [pos for pos in pred_columns if table.domain[pos].varType != orange.VarTypes.Discrete] bounds = Zero.compute_bounds(self.data[:, search_cols]) self.zero = Zero(search_cols, bounds=bounds) self.zerod_data = self.zero.zero(self.data) self.zerod_table = Orange.data.Table(table.domain, self.zerod_data.data) super(ZeroBottomUp, self).setup(self.zerod_table) def __call__(self, table, **kwargs): BottomUp.__call__(self, table, **kwargs) # unzero all clusters and final clusters self.all_clusters = map(self.zero.unzero_cluster, self.all_clusters) self.final_clusters = map(self.zero.unzero_cluster, self.final_clusters) return self.final_clusters