figure - transforming an image into vbow vector (courtesy of ian londonimage classification in pythonwith visual bag of wordsthus you can see from figure - how two-dimensional image and its corresponding feature descriptors can be easily transformed into one-dimensional vbow vector [ going into extensive details of the vbow model would not be possible in the current scopebut would like to thank my friend and fellow data scientistian londonfor helping me out with providing the two figures on vbow models would also recommend you to check out his wonderful blog article io/blog/visual-bag-of-words/which talks about using the vbow model for image classification we will now use our surf feature descriptors for our two sample images and use -means clustering on them and compute vbow vectors for each image by assigning each feature descriptor to one of the bins we will take = in this case see figure - in [ ]from sklearn cluster import kmeans km kmeans(kn_init= max_iter= surf_fd_features np array([cat_surf_fdsdog_surf_fds]km fit(np concatenate(surf_fd_features)vbow_features [for feature_desc in surf_fd_featureslabels km predict(feature_descvbow np bincount(labelsminlength=kvbow_features append(vbowvbow_df pd dataframe(vbow_featurespd concat([dfvbow_df]axis= figure - transforming surf descriptors into vbow vectors for sample images