The Internet of Things (IoT) in healthcare is becoming more and more popular in the field of research aimed at improving the effectiveness of intelligent healthcare networks and applications. Nonetheless, distinct risks affect the security and privacy of data in smart health (S-Health). IoT enables healthcare professionals to engage with patients more proactively and with greater vigilance. Smart gadgets with tiny sensors attached to them that communicate with one another to track each other's performance are part of the Internet of Things. To defend S-Health from MITM attacks. The suggested method employs two layers of machine learning algorithms for attack detection and security mechanisms, including low-cost access policies for SHRs (Smart Health Records), lightweight IoT detection schemes, and timely detection of to lessen their impact on the network. According to simulation data, the suggested Hybrid ML performs better than current methods and has a higher attack detection rate overall. The main goal of this research article is to develop an attack detection technique.