Giter Site home page Giter Site logo

tracyyxchen / bayespa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from strin/bayespa

0.0 1.0 0.0 11.83 MB

Online Max-Margin Topic Models for Accurate and Fast Text Classification [release v0.1]

Game Maker Language 92.45% Jupyter Notebook 6.21% Python 0.16% CMake 0.01% Makefile 0.11% MATLAB 0.08% C++ 0.85% C 0.12%

bayespa's Introduction

BayesPA

This repository contains code for the following paper:

Specifically, the code is a streaming implementation of MedLDA

What is MedLDA ?

Maximum Entropy Discriminant LDA (MedLDA) is a max-margin supervised topic model. It jointly trains Latent Dirichlet Allocation (LDA) with SVM, and obtains a topic representation more suitable for discriminative tasks such as classification.

What is BayesPA ?

Online Bayesian PA (BayesPA) is a generalization of classic Passive-Aggressive learning to the Bayesian and latent-variable setting. For every incoming mini-batch of documents, BayesPA first applies Bayes' rule to update the LDA topic model, then projects the posterior distribution to a region where the hinge-loss on the mini-batch data is minimized.

How to Use

The python interface of Online MedLDA is simple.

To use, simply

import medlda

To create a classifer with 2 labels and 61188 words,

pamedlda = medlda.OnlineGibbsMedLDA(num_topic = 5, labels = 2, words = 61188)

The training and inference are also straightfoward,

pamedlda.train_with_gml('../data/binary_train.gml', batchsize=64)
(pred, ind, acc) = pamedlda.infer_with_gml('../data/binary_test.gml', num_sample=100)

Please refer to docs for more detals.

Installing Online MedLDA

This release is for early adopters of this premature software. Please let us know if you have comments or suggestions. Contact: tianlinshi [AT] gmail.com

Online MedLDA is written in C++ 11, with a friendly python interface. It depends on gcc >= 4.8, python (numpy >= 1.7.0, distutils) and boost::python. To install, follow the instructions below.

Dependencies (Ubuntu)

# system dependency
sudo apt-get install libboost-all-dev gcc-4.8
sudo apt-get install python-numpy

Dependencies (OS X, Homebrew)

brew install gcc
brew install boost --cc=gcc-4.9
brew install boost-python --cc=gcc-4.9
pip install numpy scipy

Installation

sudo python setup.py install

Citation

If you use online MedLDA in your work, please cite

Shi, T., & Zhu, J. (2014). Online Bayesian Passive-Aggressive Learning. In Proceedings of The 31st International Conference on Machine Learning (pp. 378-386).

License (GPL V3)

Copyright (C) 2014 Tianlin Shi

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributeCd in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

bayespa's People

Contributors

strin 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.