Giter VIP home page Giter VIP logo

example-for-fasttext's Introduction

Example-for-Fasttext

A workable example for fasttext based on python version

fasttext模型示例(基于python)

运行

python fasttext_classifier.py

示例运行结果

Start training model, training file: data/news_fasttext_train.txt, saved model path: model/news_model.
Training over. cost 3.93s
Start evaluating model, load model from "model/news_model.bin".

Current evaluation class: "__label__affairs".
Test sample size: 1000.
Target sameple size: 1000.
TP: 1000, FP: 0, FN: 0, TN: 0.
Accuracy: 1.000
Precision: 1.000, Recall: 1.000, F1: 0.999.

Finally, model accuracy: 1.000, precision: 1.000, recall: 1.000.
Start predicting model, load model from "model/news_model.bin".
[[u'affairs'], [u'affairs'], [u'affairs'], [u'affairs'], [u'affairs'], [u'affairs'], [u'affairs'], [u'affairs'], [u'affairs'], [u'affairs']]
[[(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)], [(u'affairs', 1.0)]]

数据输入格式

  1. training data and test data
  • each line represents a sample

例如:

“想请他出任赛事嘉宾。他们决定答应佩纳的要求并请他前来参赛”。它的label是affairs。

需要处理为如下:


想 请 他 出任 赛事 嘉宾 。 他们 决定 答应 佩纳 的 要求 并 请 他 前来 参赛 。  __label__affairs

其中每一个词之间用空格隔开,最后一个词和‘__label__’之前用‘\t’隔开

  1. predict data

例如:

“想请他出任赛事嘉宾。他们决定答应佩纳的要求并请他前来参赛”。

需要处理为如下:


想 请 他 出任 赛事 嘉宾 。 他们 决定 答应 佩纳 的 要求 并 请 他 前来 参赛 。


example-for-fasttext's People

Contributors

hallyseu avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.