now that the training data has been obtainedwe must feed the data to machine learning algorithm the bag of words model will break down the training data in order to make it ready for the learning algorithm or model bag of words the bag of words is model that is used for representing text data in such way that it does not take into consideration the order of words but rather uses word counts to segment words into regions take the following sentencessentence_ "as fit as fiddlesentence_ "as you like itthe bag of words enables us to decompose text into numerical feature vectors represented by matrix to reduce our two sentences into the bag of words modelwe need to obtain unique list of all the wordsset((sentence_ sentence_ split(")this set will become our columns in the matrix the rows in the matrix will represent the documents that are being used in training the intersection of row and column will store the number of times that word occurs in the document using our two sentences as exampleswe obtain the following matrixas fit fiddle you like it sentence sentence the preceding data alone will not enable us to predict accurately the category that new documents or articles will belong to the table has some inherent flaws there may be situations where longer documents or words that occur in many of the posts reduce the precision of the algorithm stop words can be removed to make sure only relevant data is analyzed stop words include isarewasand so on since the bag of words model does not factor grammar into its analysisthe stop words can safely be dropped it is also possible to add to the list of stop words that one feels should be exempted from final analysis