def infer(self, path): ''' 载入预测集 ''' logger.info("load inferset from %s" % path) mode = TaskMode.create_infer() return self._parse_creator(path, mode)
def train(self, path): ''' 载入数据集 ''' logger.info("load trainset from %s" % path) mode = TaskMode.create_train() return self._parse_creator(path, mode)
def test(self, path): ''' 载入测试集 ''' logger.info("load testset from %s" % path) mode = TaskMode.create_test() return self._parse_creator(path, mode)
def infer(self, path): ''' Load infer set. ''' logger.info("load inferset from %s" % path) self.path = path self.mode = TaskMode.create_infer() return self._parse
def train(self, path): ''' Load trainset. ''' logger.info("load trainset from %s" % path) self.mode = TaskMode.create_train() self.path = path return self._parse
def test(self, path): ''' Load testset. ''' logger.info("load testset from %s" % path) self.path = path self.mode = TaskMode.create_test() return self._parse
def infer(self, path): """ load infer set @path: infer set path """ logger.info("start infer reader from %s" % path) mode = TaskMode.create_infer() return self._reader(path, mode)
def test(self, path): """ load test set @path: test set path """ logger.info("start test reader from %s" % path) mode = TaskMode.create_test() return self._reader(path, mode)
def train(self, path): """ load train set @path: train set path """ logger.info("start train reader from %s" % path) mode = TaskMode.create_train() return self._reader(path, mode)
def infer(self): ''' Load inferset. ''' logger.info("load inferset from %s" % self.train_path) self.mode = TaskMode.create_infer() with open(self.train_path) as f: reader = csv.DictReader(f) for row_id, row in enumerate(reader): rcd = self._parse_record(row) if rcd: yield rcd
def __init__(self, train_path, n_records_as_test=-1, fields=None, feature_dims=None): self.train_path = train_path self.n_records_as_test = n_records_as_test self.fields = fields # default is train mode. self.mode = TaskMode.create_train() self.categorial_dims = [ feature_dims[key] for key in categorial_features + ['hour'] ] self.id_dims = [feature_dims[key] for key in id_features]
def test(self): ''' Load testset. ''' logger.info("load testset from %s" % self.train_path) self.mode = TaskMode.create_test() with open(self.train_path) as f: reader = csv.DictReader(f) for row_id, row in enumerate(reader): # skip top n lines if self.n_records_as_test > 0 and row_id > self.n_records_as_test: break rcd = self._parse_record(row) if rcd: yield rcd
def train(self): ''' 载入训练集 ''' logger.info("load trainset from %s" % self.train_path) self.mode = TaskMode.create_train() with open(self.train_path) as f: reader = csv.DictReader(f) for row_id, row in enumerate(reader): # 跳过前n条记录 if self.n_records_as_test > 0 and row_id < self.n_records_as_test: continue rcd = self._parse_record(row) if rcd: yield rcd
def __init__(self): self.mode = TaskMode.create_train()