Smart cities leverage technologies such as Cloud computing, the Internet of Things (IoT), artificial intelligence (AI), and data analytics to collect and analyze data on various aspects of city life, including transportation, energy usage, public safety, and environmental factors. In such an environment, security is important to protect the data collected by various devices and systems from unauthorized access or misuse. Intrusion Detection Systems (IDS) are critical components of cyber security, designed to identify and prevent malicious activities on computer networks. Machine learning (ML) techniques have emerged as a promising approach to enhance IDS performance by automating the detection of anomalies and reducing false positives. This paper provides an overview of IDS systems and reviews some of the most popular ML algorithms used in IDS. A REPOStack model is proposed, which is a hybrid of Recursive Feature Elimination (RFE), Self-Adaptive Equilibrium Optimizer with Particle Swarm Optimization (SAEO_PSO), and Probabilistic Stacked Ensemble of Adaboost, Support Vector Machine (SVM), Deep Neural Network (DNN), and XGBoost. Adboost, SVM, and DNN are used as base learners, and XGboost is used as a meta-learner. REPOStack is tested on benchmark datasets NSLKDD, UNSW-NB15, and CICIDS. The results show improved accuracy, sensitivity, precision, specificity, and F1 score.