the list test_data is passed to the count_vect transform function to obtain the vectorized form of the test data to obtain the term frequency--inverse document frequency representation of the test datasetwe call the transform method of the matrix_transformer object to predict which category the docs may belong towe do the followingprediction model predict(new_tfidfthe loop is used to iterate over the predictionshowing the categories they are predicted to belong tofor doccategory in zip(test_dataprediction)print('% =% (doctraining_data target_names[category])when the loop has run to completionthe phrasetogether with the category that it may belong tois displayed sample output is as follows'my god is good=soc religion christian 'arm chip set will rival intel=comp graphics all that we have seen up to this point is prime example of supervised learning we started by loading posts whose categories are already known these posts were then fed into the machine learning algorithm most suited for text processing based on the naive bayes theorem set of test post fragments were supplied to the model and the category was predicted to explore an example of an unsupervised learning algorithmwe shall study the -means algorithm for clustering some data an unsupervised learning example category of learning algorithms is able to discover inherent groups that may exist in set of data an example of these algorithms is the -means algorithm -means algorithm the -means algorithm uses the mean points in given dataset to cluster and discover groups within the dataset is the number of clusters that we want and are hoping to discover after the -means algorithm has generated the groupingswe can pass it additional but unknown data for it to predict to which group it will belong