本文整理汇总了Python中Preprocessor.Preprocessor.process_custom_data方法的典型用法代码示例。如果您正苦于以下问题:Python Preprocessor.process_custom_data方法的具体用法?Python Preprocessor.process_custom_data怎么用?Python Preprocessor.process_custom_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preprocessor.Preprocessor
的用法示例。
在下文中一共展示了Preprocessor.process_custom_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Preprocessor import Preprocessor [as 别名]
# 或者: from Preprocessor.Preprocessor import process_custom_data [as 别名]
def main():
pp = Preprocessor()
print 'processing custom data, computing bows...'
tdpath = 'dataset/test/sms-data'
pp.process_custom_data(tdpath)
fm = FeatureModel()
print 'converting custom data to fvs...'
fm.compute_custom_fv_matrix('custom')
tdpath = 'bin_data/custom_fv.npy'
cpath = 'bin_data/mnb-classifier.npy'
data = np.load('bin_data/custom-data.npy').item()
tester = Tester(tdpath,cpath)
print 'predicting labels for custom data...'
results = tester.predict_labels_for_custom_data(data)
with open('output/results.txt','w') as textfile:
for msg in results:
line = '%s -> %s\n' % (msg,results[msg])
textfile.write(line)
textfile.close()
print 'Results written to results.txt'