Nowadays, skin cancer is one of the most dangerous forms of cancer found in humans. There are various types of skin cancer, like basal, melanoma, carcinoma, and the squamous cell from which the melanoma is unpredictable. Thus, skin cancer detection in the early stage is very useful to treat it successfully. Hence, this study introduces a new algorithm called social bat optimisation algorithm for skin cancer detection. Initially, the pre-processing is done for the input image to eliminate the noise and artefacts present in the image. Then, the pre-processed image is fed to the feature extraction step where the features are extracted based on convolutional neural network features, and the local pixel pattern-based texture feature (local PPBTF). Here, the PPBTF is the combination of texture features and pixel pattern-based features in which the equation of PPBTF is modified based on the local binary pattern. Subsequently, the classification is done based on the extracted features using a deep stacked auto-encoder, which is trained by the proposed social bat optimisation. The performance of skin cancer detection based on the proposed model is evaluated based on accuracy, sensitivity, and specificity. The proposed model achieves the maximal accuracy of 93.38%, maximal sensitivity of 95%, and the maximal specificity of 96% for K-fold.