for those who are interested and adventurous enougha wikipedia search will provide all the equations behind these algorithms at the following linkhoweverwe can understand that this is at high level and there is sort of fable which underlies these models in this fablethere are topics that are fixed this lacks clarity which documentsfor examplelet' say we have only three topics at presentmachine learning python baking each topic has list of words associated with it this book would be mixture of the first two topicsperhaps percent each thereforewhen we are writing itwe pick half of our words from the machine learning topic and half from the python topic in this modelthe order of words does not matter the preceding explanation is simplification of the realityeach topic assigns probability to each word so that it is possible to use the word "flourwhen the topic is either machine learning or bakingbut more probable if the topic is baking of coursewe do not know what the topics are otherwisethis would be different and much simpler problem our task right now is to take collection of text and reverse engineer this fable in order to discover what topics are out there and also where each document belongs building topic model unfortunatelyscikit-learn does not support latent dirichlet allocation thereforewe are going to use the gensim package in python gensim is developed by radim rehurekwho is machine learning researcher and consultant in the czech republic we must start by installing it we can achieve this by running one of the following commandspip install gensim easy_install gensim we are going to use an associated press (apdataset of news reports this is standard datasetwhich was used in some of the initial work on topic modelsfrom gensim import corporamodelssimilarities corpus corpora bleicorpus(/data/ap/ap dat''/data/ap/vocab txt'