In this article, human activity recognition (HAR) attempts to recognize the activities of an object in a multistory building from data retrieved via smartphone-based sensors (SBSs). Most publications based on machine learning (ML) report the development of a suitable architecture to improve classification accuracy by increasing the parameters of the architecture pertaining to HAR. Due to robust and automated ML, it is quite possible to develop a versatile approach to improve the accuracy of HAR. This research proposes an optimal ensemble HAR and floor detection (OEC-HAFD) scheme based on automated learning (AutoML) and weighted soft voting (WSF) using SBS to improve the recognition rate. The proposed HAR-FD scheme is developed based on twofold mechanisms. First, an AutoML paradigm is employed to find optimal supervised models based on performance. Second, top-ranked (optimal) models are combined using the WSF mechanism to classify HAR on various floors of a multistory building. The proposed scheme is developed based on real-time SBS: accelerometer and barometer data. The accelerometer data are used to detect activity by observing the magnitude of the sensor measurements. Similarly, the barometer sensor detects floor height by using pressure and altitude data. Furthermore, we analyze the performance of the proposed optimal ensemble classifier (OEC) and compare them with the state-of-the-art classifiers. Based on the result analysis, it is clearly seen that the proposed OEC outperforms the performance of the individual classifiers. Moreover, our proposed HAR-FD can be leveraged as a robust solution to accurately recognize human activities in multistory buildings compared to the existing standalone models.