UTI (Urinary Tract Infection) has become common with maximum error rates in diagnosis. With the current progress on DM (Data Mining) based algorithms, several research projects have tried such algorithms due to their ability in making optimal decisions and efficacy in resolving complex issues. However, conventional research has failed to attain accurate predictions due to improper feature selection. To resolve such existing pitfalls, this research intends to employ suitable ML (Machine Learning)-based algorithms for predicting UTI in IoT-Fog environments, which will be applicable to a smart toilet. Additionally, bio-inspired algorithms have gained significant attention in recent eras due to their capability in resolving complex optimization issues. Considering this, the current study proposes MFB-FA (Modified Flashing Behaviour-based Firefly Algorithm) for feature selection. This research initializes the FF (Firefly) population and interchanges the constant absorption coefficient value with the chaotic maps as the chaos possesses an innate ability to evade getting trapped in local optima with the improvement in determining global optimum. Further, GM (Gaussian Map) is taken into account for moving all the FFs to a global optimum in an individual iteration. Due to such nature, this algorithm possesses a better optimization ability than other swarm intelligence approaches. Finally, classification is undertaken by the proposed MANN-AM (Modified Artificial Neural Network with Attention Mechanism). The main intention for proposing this network involves its ability to focus on small and significant data. Moreover, ANNs possess the ability for learning and modelling complex and non-linear relationships, in which the present study considers it. The proposed method is compared internally by using Random Forest, Naive Bayes and K-Nearest Neighbour to show the efficacy of the proposed model. The overall performance of this study is assessed with regard to standard performance metrics for confirming its optimal performance in UTI prediction. The proposed model has attained optimal values such as accuracy as 0.99, recall as 0.99, sensitivity as 1, precision as 1, specificity as 0.99 and f1-score as 0.99.