FastText简单实践

别等时光非礼了梦想. 提交于 2020-01-17 04:03:09

fastText原理和文本分类实战

https://blog.csdn.net/feilong_csdn/article/details/88655927

 

 Python interface 

https://github.com/salestock/fastText.py

 

import fasttext

root_path = "/Users/documents/"

train_file = root_path + "target.train"
valid_file = root_path + "target.valid"

model_save_path = root_path + "model_py"
def showResult(classifier, valid_file):
	result = classifier.test(valid_file)
	print("Number of examples:", result[0])
	print("P@1:", result[1])
	print("R@1:", result[2])
	

classifier = fasttext.train_supervised(input=train_file, epoch=15)
#classifier.save_model(model_save_path)


#classifier = fasttext.load_model(model_save_path)
showResult(classifier, valid_file)
result = classifier.predict("股票失败")
print(result)

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!