def extend(self, other, patterns = None) : if self.__class__ != other.__class__ : raise ValueError, 'datasets should be the same class' if patterns is None : patterns = range(len(other)) # first check if ids have compatible hash values : for id in other.featureID : if (hash(id) in self.featureKeyDict and id != self.featureID[self.featureKeyDict[hash(id)]]) : raise ValueError, 'bad hash' # recompute featureID related stuff self.featureKey = misc.union(self.featureKey, other.featureKey) self.featureKey.sort() self.featureKeyDict.clear() for i in range(len(self.featureKey)) : self.featureKeyDict[self.featureKey[i]] = i featureIDs = misc.union(self.featureID, other.featureID) self.featureID = [None for i in range(len(self.featureKey))] for id in featureIDs : self.featureID[self.featureKeyDict[hash(id)]] = id self.extendX(other, patterns) self.labels.extend(other.labels, patterns)
def extend(self, other, patterns=None): if self.__class__ != other.__class__: raise ValueError, 'datasets should be the same class' if patterns is None: patterns = range(len(other)) # first check if ids have compatible hash values : for id in other.featureID: if (hash(id) in self.featureKeyDict and id != self.featureID[self.featureKeyDict[hash(id)]]): raise ValueError, 'bad hash' # recompute featureID related stuff self.featureKey = misc.union(self.featureKey, other.featureKey) self.featureKey.sort() self.featureKeyDict.clear() for i in range(len(self.featureKey)): self.featureKeyDict[self.featureKey[i]] = i featureIDs = misc.union(self.featureID, other.featureID) self.featureID = [None for i in range(len(self.featureKey))] for id in featureIDs: self.featureID[self.featureKeyDict[hash(id)]] = id self.extendX(other, patterns) self.labels.extend(other.labels, patterns)
def selectFeatures(self, data, **args) : labels = data.labels features = [] for k in range(data.labels.numClasses) : data2 = labels.oneAgainstRest(data, k) features2 = self.featureSelector.selectFeatures(data2) features = misc.union(features, features2) data.attachLabels(labels) return features
def selectFeatures(self, data, **args): labels = data.labels features = [] for k in range(data.labels.numClasses): data2 = labels.oneAgainstRest(data, k) features2 = self.featureSelector.selectFeatures(data2) features = misc.union(features, features2) data.attachLabels(labels) return features