Sentiment is employed in various fields, such as collecting web-based opinions for the formulation of governmental policies, measuring employee and customer satisfaction levels in business organizations, and measuring the sentiment of the public in political and security matters. The field has recently faced new challenges since algorithms must operate with highly unstructured sentiment data from social media. In this study, the authors present a new stacking ensemble method that combines the lexicon-based approach with machine learning algorithms to improve the sentiment analysis of tweets. Due to the complexity of the text with very ill-defined syntactic and grammatical patterns, using lexicon-based techniques to extract sentiment from the content is proposed. On the same note, the contextual and nuanced aspects of sentiment are inferred through machine learning algorithms. A sophisticated bat algorithm that uses an Elman network as a meta-classifier is then employed to classify the extracted features accurately. Substantial evidence from three datasets that are readily available for public analysis re-affirms the improvements this innovative approach brings to sentiment classification.