The aim of this work is to develop a comprehensive method for classifying sources in large sky surveys and we apply the techniques to the VIMOS Public Extragalactic Redshift Survey (VIPERS). Using the optical (u*, g, r, i) and NIR data (z, Ks), we develop a classifier, based on broad-band photometry, for identifying stars, AGNs and galaxies improving the purity of the VIPERS sample. Support Vector Machine (SVM) supervised learning algorithms allow the automatic classification of objects into two or more classes based on a multidimensional parameter space. In this work, we tailored the SVM for classifying stars, AGNs and galaxies, and applied this classification to the VIPERS data. We train the SVM using spectroscopically confirmed sources from the VIPERS and VVDS surveys. We tested two SVM classifiers and concluded that including NIR data can significantly improve the efficiency of the classifier. The self-check of the best optical + NIR classifier has shown a 97% accuracy in the classification of galaxies, 97 for stars, and 95 for AGNs in the 5-dimensional colour space. In the test on VIPERS sources with 99% redshift confidence, the classifier gives an accuracy equal to 94% for galaxies, 93% for stars, and 82% for AGNs. The method was applied to sources with low quality spectra to verify their classification, and thus increasing the security of measurements for almost 4 900 objects. We conclude that the SVM algorithm trained on a carefully selected sample of galaxies, AGNs, and stars outperforms simple colour-colour selection methods, and can be regarded as a very efficient classification method particularly suitable for modern large surveys.