本文整理汇总了Python中feature_extractor.FeatureExtractor.to_seti方法的典型用法代码示例。如果您正苦于以下问题:Python FeatureExtractor.to_seti方法的具体用法?Python FeatureExtractor.to_seti怎么用?Python FeatureExtractor.to_seti使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feature_extractor.FeatureExtractor
的用法示例。
在下文中一共展示了FeatureExtractor.to_seti方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_seti
# 需要导入模块: from feature_extractor import FeatureExtractor [as 别名]
# 或者: from feature_extractor.FeatureExtractor import to_seti [as 别名]
def generate_seti(filenames, for_test=False):
files = []
for filename in filenames:
for fname in glob.glob(filename):
files.append(fname)
print 'logs_to_seti reading from files: %s' % (str(files))
setis = []
# Read each file where each row represents a training example.
for fname in files:
num_lines = 0
num_invalid_lines = 0
num_bad_entry_lines = 0
bad_entry_lines = []
# Read examples from file.
with open(fname, 'rb') as csvfile:
reader = csv.reader(csvfile)
reader.next() # ignore header
i = 0
invalid_lines = []
for csv_line in reader:
num_lines += 1
bad_line, reason = is_bad_line(csv_line)
if bad_line:
num_invalid_lines += 1
continue
#try:
renter_form, err = _to_renter_form(csv_line)
if renter_form is None:
print err
num_bad_entry_lines += 1
bad_entry_lines.append(csv_line)
continue
fe = FeatureExtractor(for_test=for_test)
seti = fe.to_seti(renter_form)
setis.append(seti)
#except Exception as e:
# num_invalid_lines += 1
# invalid_lines.append(i)
# print 'e: %s' % (str(e))
# PrintException()
# print 'Could not parse line %d. %d cols. \n%s' % (i, len(csv_line), csv_line)
i += 1
# Finished handling file.
print 'File: %s' % fname
valid_lines = num_lines-num_invalid_lines-num_bad_entry_lines
print 'Num lines: %d. Valid: %d. Invalid: %d. Bady entry: %d' % (num_lines, valid_lines, num_invalid_lines, num_bad_entry_lines)
if len(setis) == 0:
raise Exception('No setis generated!')
return setis