Git Product home page Git Product logo

topic_model_lda_hyper_params_opt's Introduction

LDA topic model hyper params optimization

Summary

Two implementations of LDA model:

  • Gensim LDA model
  • Guided LDA

For each implementation there are several functions to optimize hyper parameters of LDA model in two stages:

  • Stage 1 - optimize almost all params with fixed interval for number of topics
  • Stage 2 - optimize anly number of topics with fixed almost all params from Stage 1 optimization

Functions are stored in topic_model_hyper_param_opt.py module. Examples of their application are in notebooks.

Notebooks and Scripts description

Script with functions - topic_model_hyper_param_opt.py

This script contains a set of functions. These functions helps to

  • Preprocess texts
  • Optimize hyper params of LDA topic model
  • Plot the results of hyper params optimization
  • Run experiments with hyper params opt

Notebook - gensim_lda_hyperopt_example.ipynb

This notebook provides an example of implementation functions of two stage optimization process. This notebook contains a pipeline with steps from reading the data to plot the results. The proposed pipeline have several steps:

  • Read the data.
  • Preprocessing.
  • Preparing objects for model - corpus and id2word.
  • Stage 1 hyper params opt - optimize params of LDA model with fixed limited interval of number of topics. Optimal values for almost all params except number of topics are obtained as a result of this step.
  • Stage 2 hyper params opt - optimize number of topics with fixed other params of LDA model. Fixed other params - obtained optimal params from Stage 1. This step helps to optimize only number of topics.
  • Build a model with optimal params
  • Plots - params values vs. loss
  • Model description with prints, word clouds, pyLDAvis and the most representative documents for each topic

Notebook - gensim_lda_experiment_example.ipynb

A notebook provides an example of implementation experiments. Each experiment is a whole pipeline in one function which allows to:

  • Preprocess data
  • Create objects for model
  • Optimize LDA model hyper params on Stage 1 and Stage 2
  • Save trials of hyperopt in dataframe format
  • Display and save plots

So there is the example how to run several experiments to choose preprocessing params of pipeline and LDA model optimal params.

Notebook - guided_lda_hyperopt_example.ipynb

Guided LDA allows us to seed initial topics. Guided LDA tries to fit to these seeds as target topics with some seed_confidence which represent an allowed deviation from seeded topics.

topic_model_lda_hyper_params_opt's People

Contributors

dany-kuznetsov avatar

Watchers

James Cloos 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.