def __init__(self, config_file, data_file): vote_parser = Parser(config_file, data_file) vote_parser.parse_config() self.D = vote_parser.parse_data()
data = self.data["testing"]["data"][i].T labels = self.data["testing"]["labels"][i].T else: data = np.append(data, self.data["testing"]["data"][i].T, axis=0) labels = np.append(labels, self.data["testing"]["labels"][i].T, axis=0) return data, labels def testing(self, c=20): k = c/(100/self.k) data, labels = None, None for i in range(self.k-1, self.k-k-1, -1): if data is None and labels is None: data = self.data["testing"]["data"][i].T labels = self.data["testing"]["labels"][i].T else: data = np.append(data, self.data["testing"]["data"][i].T, axis=0) labels = np.append(labels, self.data["testing"]["labels"][i].T, axis=0) return data, labels if __name__=="__main__": vote_parser = Parser('../data/vote/vote.config', '../data/vote/vote.data') vote_parser.parse_config() D = vote_parser.parse_data() print D.shape ucifolder = UCIFolder(D, normalize=False, shuffle=False) for c in [5,10,15,20,30,50,80]: train_data, train_labels = ucifolder.training(c) test_data, test_labels = ucifolder.testing() print train_data.shape, test_data.shape