Giter Site home page Giter Site logo

ldas's Introduction

Implementation of LDAs

This repository is an implementation of LDA.
Implementation contents are as follows  

  1. Latent Dirichlet Allocation as a probabilistic generative model.
  2. Multimodal Dirichlet Allocation as a probabilistic generative model.

Latent Dirichlet Allocation

Original paper

What the LDA contains:

  • /LDA/lda.py:LDA by using Collapsed Gibbs sampler with Python.You need to decide the number of topic.
def main():
    n = 100 # データの水増し用の変数
    topic = 3 # トピック数を指定
    data = np.loadtxt( root , dtype=np.int32)*n # 発生回数にnをかけて水増し可能
    #print(data)
    lda( data , topic )

※Before running this script, you need to run /LDA/bow/bow.py which creates a BoW file

  • /LDA/bow/bow.py: It can generate BoW file which is used by /LDA/lda.py from /LDA/bow/text.txt
  • /LDA/bow/text.txt: You can write sentences.
    ※Sentences must be separated by spaces for each word.
    • For example
    内藤 は 彼女 が できない
    内藤 は 理想 が 高すぎる
    あの 店 の ラーメン は おいしい
    おいしい 店 の ごはん を 食べる
    室 は ずっと 踊って いる
    室 は 顔芸 を して いる
    

Usage:

  1. Write sentences in /LDA/bow/text.txt
  2. Create BoW:python3 /LDA/bow/bow.py
  3. python3 /LDA/lda.py

Requirement
Python3.X and the following modules are required

import codecs
import numpy as np
from scipy.sparse import load_npz
import random
import math
import matplotlib.pyplot as plt

References:

Multimodal Latent Dirichlet Allocation

What the MLDA contains:

  • /MLDA/mlda.py:MLDA by using Collapsed Gibbs sampler with Python.You need to decide the number of topic.
def main():
    topic = 3
    data = []
    data.append( np.loadtxt( "./bof/histogram_v.txt" , dtype=np.int32) )
    data.append( np.loadtxt( "./bow/histogram_w.txt" , dtype=np.int32)*5 )
    mlda( data, topic, 100, "learn_result" )

    data[1] = None
    mlda( data, topic, 10, "recog_result" , "learn_result" )

※Before running this script, you need to run /MLDA/bow/bow.py and /MLDA/bof/bof.py which create BoW and BoF file

  • /MLDA/bow/bow.py: It can generate BoW file which is used by /MLDA/mlda.py from /MLDA/bow/text.txt

  • /MLDA/bow/text.txt: You can write sentences.
    ※Sentences must be separated by spaces for each word.

    • For example
    内藤 は 彼女 が できない
    内藤 は 理想 が 高すぎる
    あの 店 の ラーメン は おいしい
    おいしい 店 の ごはん を 食べる
    室 は ずっと 踊って いる
    室 は 顔芸 を して いる
    
  • /MLDA/bof/bof.py: It can generate BoF file which is used by /MLDA/mlda.py from /MLDA/bof/images/*.png

Usage:

  1. Write sentences in /MLDA/bow/text.txt
  2. Create BoW:python3 /MLDA/bow/bow.py
  3. Create BoF:python3 /MLDA/bof/bof.py
  4. python3 /MLDA/mlda.py

Requirement:

Python3.X and the following modules are required

import numpy as np
import random
import math
import pylab
import pickle
import os
import sys
import cv2
import glob
import codecs

References:

ldas's People

Contributors

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