Code Monkey home page Code Monkey logo

markov-chain's Introduction

What we do here:

  1. take a user activity log
  2. execute the script that trains a Markov Chain and outputs it as a .gefx file
  3. open the file

More details:

Markov Chain definition

We have a set of states, S = {s[1], s[2], ..., s[N]} (these states may represent some events in user logs). The process starts in one of these states and moves successively from one state to another. Each move is called a step. If the chain is currently in state s[i] , then it moves to state s[j] at the next step with a probability denoted by p[i][j], and this probability does not depend upon which states the chain was in before the current. Markov chain is defined by its “Transition matrix” P (containing p[i][j]) of size NxN, where N – is the quantity of nodes in the chain. In our particular case we built a chain to visualize user activity in some MOOC. Each node - is a certain kind of event that happened to users. Each line in the data file - is a specific event that happened to a specific user in a specific time

Data format

The data of user activity should include identification of a user, name of a "step" committed by a user and the time of that step – so that for each user it would be possible to represent his activity as sequence of state-nodes, following one another. The nodes of the chain, in the essence, represent events happening to our user. The data format should be as in the file worklist.csv in the repo. First column - user id, second - event name, third - time in excel-like format represented as a number - but the table should have no header

How to launch

Run the script MarkovChain.py in any Python 3 IDE having your user activity log in a format described earlier in your working directory. By default the data file should be named worklist.csv. The script will create a Graph.gexf - a graph file representing the trained Markov Chain.

Visualize

Use Gephi or any other graph visualization tool that supports the .gefx format to open the resulting file. After some customization within Gephi project you may obtain something like General.gephi file in the repo (also saved as .pdf picture in the repo for the sake of clarity).

For more details read comments in the code in MarkovChain.py

markov-chain's People

Contributors

bartolomeud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

markov-chain's Issues

Data Source

Hi, can you please tell me how exactly you prepared the csv file? I am using my own data, I made a csv file where I put the user ID in the first column, event in the second column, and time in the 3rd column, but it is not working with my data.

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.