The Classification of Music by the Genre Using the KNN Classifier

  • Daniel KostrzewaEmail author
  • Robert Brzeski
  • Maciej Kubanski
Conference paper
Part of the Communications in Computer and Information Science book series (CCIS, volume 928)


The article presents the possibility of classifying music tracks according to their musical genre. This issue is interesting because it is difficult to find solutions that look for similarity between songs based on their waveforms, as in this work. This article shows that such a classification is possible. For this process, the KNN classifier was used, for which it is possible to apply different metrics (metric spaces). The article shows the validity of testing different distance measures in the classification process. The analysis of music tracks and assignment to the appropriate genre is carried out, on the basis of attributes describing the music track. These attributes are obtained using the jAudio library. The development of further research in this area may allow finding other suitable music not only on the basis of historical data about the user (what he was listening to along with the music track) but also directly on the basis of the genre of the given song.


Classification Accuracy Kappa Metric Song Music track Music genre jAudio KNN 



This work was partly supported by BKM-509/RAU2/2017 and by Statutory Research funds of Institute of Informatics, Silesian University of Technology, Gliwice, Poland (grant No BK-213/RAU2/2018).


  1. 1.
    Agrawal, R., Imielinski, T., Swami, A.: Database mining: a performance perspective. IEEE Trans. Knowl. Data Eng. 5(6), 914–925 (1993)CrossRefGoogle Scholar
  2. 2.
    Aha, D.W., Kibler, D., Albert, M.K.: Instance-based learning algorithms. Mach. Learn. 6(1), 37–66 (1991)Google Scholar
  3. 3.
    Aksoy, S., Haralick, R.M.: Feature normalization and likelihood-based similarity measures for image retrieval. Pattern Recognit. Lett. 22(5), 563–582 (2001)CrossRefGoogle Scholar
  4. 4.
    Bach, M., Werner, A.: Cost-Sensitive Feature Selection for Class Imbalance Problem. In: Borzemski, L., Świątek, J., Wilimowska, Z. (eds.) ISAT 2017. AISC, vol. 655, pp. 182–194. Springer, Cham (2018). Scholar
  5. 5.
    Bach, M., Werner, A., Żywiec, J., Pluskiewicz, W.: The study of under-and over-sampling methods utility in analysis of highly imbalanced data on osteoporosis. Inf. Sci. 384, 174–190 (2017)CrossRefGoogle Scholar
  6. 6.
    Basili, R., Serafini, A., Stellato, A.: Classification of musical genre: a machine learning approach. In: ISMIR (2004)Google Scholar
  7. 7.
    Ben-David, A.: Comparison of classification accuracy using Cohens Weighted Kappa. Exp. Syst. Appl. 34(2), 825–832 (2008)CrossRefGoogle Scholar
  8. 8.
    Costa, E., Lorena, A., Carvalho, A., Freitas, A.: A review of performance evaluation measures for hierarchical classifiers. In: Evaluation Methods for Machine Learning II: Papers from the AAAI-2007 Workshop, pp. 1–6 (2007)Google Scholar
  9. 9.
    Hamel, P., Eck, D.: Learning features from music audio with deep belief networks. In: ISMIR, vol. 10, Utrecht, The Netherlands, pp. 339–344 (2010)Google Scholar
  10. 10.
    Henaff, M., Jarrett, K., Kavukcuoglu, K., LeCun, Y.: Unsupervised learning of sparse features for scalable audio classification. In: ISMIR, vol. 11. Citeseer (2011)Google Scholar
  11. 11.
  12. 12.
    Kostrzewa, D., Brzeski, R.: Adjusting parameters of the classifiers in multiclass classification. In: Kozielski, S., Mrozek, D., Kasprowski, P., Małysiak-Mrozek, B., Kostrzewa, D. (eds.) BDAS 2017. CCIS, vol. 716, pp. 89–101. Springer, Cham (2017). Scholar
  13. 13.
    Kostrzewa, D., Brzeski, R.: The data dimensionality reduction in the classification process through greedy backward feature elimination. In: Gruca, A., Czachórski, T., Harezlak, K., Kozielski, S., Piotrowska, A. (eds.) ICMMI 2017. AISC, vol. 659, pp. 397–407. Springer, Cham (2018). Scholar
  14. 14.
    Kostrzewa, D., Brzeski, R.: Parametric optimization of the selected classifiers in binary classification. In: Król, D., Nguyen, N.T., Shirai, K. (eds.) ACIIDS 2017. SCI, vol. 710, pp. 59–69. Springer, Cham (2017). Scholar
  15. 15.
    Kubanski, M.: Znajdowanie utworow podobnych metoda najblizszego sasiada (in polish): bachelor thesis. SUT, Gliwice, Poland (2018)Google Scholar
  16. 16.
    Lee, C.H., Shih, J.L., Yu, K.M., Su, J.M.: Automatic music genre classification using modulation spectral contrast feature. In: 2007 IEEE International Conference on Multimedia and Expo, pp. 204–207. IEEE (2007)Google Scholar
  17. 17.
    Li, M., Sleep, R.: Genre classification via an LZ78-based string kernel. In: ISMIR, pp. 252–259 (2005)Google Scholar
  18. 18.
    Liu, H., Motoda, H.: Feature Selection for Knowledge Discovery and Data Mining, vol. 454. Springer, New York (2012).
  19. 19.
    McEnnis, D., McKay, C., Fujinaga, I.: Overview of on-demand metadata extraction network (OMEN). In: Proceedings of the Seventh International Conference on Music Information Retrieval (ISMIR 2006) (2006)Google Scholar
  20. 20.
    McEnnis, D., McKay, C., Fujinaga, I., Depalle, P.: jAudio: Additions and improvements. In: ISMIR, pp. 385–386 (2006)Google Scholar
  21. 21.
    McKay, C., Fujinaga, I., Depalle, P.: jAudio: a feature extraction library. In: Proceedings of the International Conference on Music Information Retrieval, pp. 600–603 (2005)Google Scholar
  22. 22.
    Mehra, N., Gupta, S.: Survey on multiclass classification methods (2013)Google Scholar
  23. 23.
    Pampalk, E., Flexer, A., Widmer, G., et al.: Improvements of audio-based music similarity and genre classificaton. In: ISMIR, vol. 5, London, UK, pp. 634–637 (2005)Google Scholar
  24. 24.
    Powers, D.M.: Evaluation: from precision, recall and F-measure to roc, informedness, markedness and correlation (2011)Google Scholar
  25. 25.
    Ricci, F., Avesani, P.: Data compression and local metrics for nearest neighbor classification. IEEE Trans. Pattern Anal. Mach. Intell. 21(4), 380–384 (1999)CrossRefGoogle Scholar
  26. 26.
    Scaringella, N., Zoia, G., Mlynek, D.: Automatic genre classification of music content: a survey. IEEE Sig. Process. Mag. 23(2), 133–141 (2006)CrossRefGoogle Scholar
  27. 27.
    Schweizer, B., Sklar, A.: Statistical metric spaces. Pacific J. Math 10(1), 313–334 (1960)MathSciNetCrossRefGoogle Scholar
  28. 28.
    Sigtia, S., Dixon, S.: Improved music feature learning with deep neural networks. In: 2014 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 6959–6963. IEEE (2014)Google Scholar
  29. 29.
    Silla, C.N., Koerich, A.L., Kaestner, C.A.: A machine learning approach to automatic music genre classification. J. Braz. Comput. Soc. 14(3), 7–18 (2008)CrossRefGoogle Scholar
  30. 30.
    Simsekli, U.: Automatic music genre classification using bass lines. In: 2010 20th International Conference on Pattern Recognition (ICPR), pp. 4137–4140. IEEE (2010)Google Scholar
  31. 31.
    Tzanetakis, G., Cook, P.: Musical genre classification of audio signals. IEEE Trans. Speech Audio Process. 10(5), 293–302 (2002)CrossRefGoogle Scholar
  32. 32.
    Vitányi, P.M.: Information distance in multiples. IEEE Trans. Inf. Theory 57(4), 2451–2456 (2011)MathSciNetCrossRefGoogle Scholar
  33. 33.
    Weinberger, K.Q., Saul, L.K.: Distance metric learning for large margin nearest neighbor classification. J. Mach. Learn. Res. 10(Feb), 207–244 (2009)Google Scholar
  34. 34.
  35. 35.
    Werenski, S.: Topologia (in Polish). Politechnika Radomska, Wydawnictwo (2008)Google Scholar
  36. 36.
    West, K., Cox, S.: Features and classifiers for the automatic classification of musical audio signals. In: ISMIR (2004)Google Scholar
  37. 37.
    Wu, X., et al.: Top 10 algorithms in data mining. Knowl. Inf. Syst. 14(1), 1–37 (2008)CrossRefGoogle Scholar
  38. 38.
    Xu, C., Maddage, N.C., Shao, X., Cao, F., Tian, Q.: Musical genre classification using support vector machines. In: Proceedings of the 2003 IEEE International Conference on Acoustics, Speech, and Signal Processing, ICASSP 2003, vol. 5, pp. V–429. IEEE (2003)Google Scholar
  39. 39.
    Zheng, J., Oussalah, M.: Automatic system for music genre classification. ntM 1, 1 (2006)Google Scholar
  40. 40.
    Zyt, J., Klosgen, W., Zytkow, J.: Handbook of Data Mining and Knowledge Discovery (2002)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2018

Authors and Affiliations

  • Daniel Kostrzewa
    • 1
    Email author
  • Robert Brzeski
    • 1
  • Maciej Kubanski
    • 1
  1. 1.Institute of InformaticsSilesian University of TechnologyGliwicePoland

Personalised recommendations