The latest technologies and communication protocols are arousing a keen interest in automation, in which the field of home area networks is the most prominent area to work upon toward solving the issues and challenges faced by wireless home area networks regarding adaptability, reliability, cost, throughput, efficiency, and scalability. However, managing the immense number of communication devices on the premises of a smart home is a challenging task. Moreover, the Internet of Things (IoT) is an emerging global trend with billions of smart devices to be connected in the near future resulting in a huge amount of diversified data. The continuous expansion of the IoT network causes complications and vulnerabilities due to its dynamic nature and heterogeneous traffic. In the applications of IoT, the wireless sensor network (WSN) plays a major role, and to take benefits from WSN, medium access control (MAC) is the primary protocol to optimize, which helps in allocating resources to a huge number of devices in the smart home environment. Furthermore, artificial intelligence is highly demanded to enhance the efficiency of existing systems and IoT applications. Therefore, the purpose of this research paper is to achieve an optimized medium access control protocol through machine learning. The machine learning classifier, e.g., random forest (RF) and linear regression model, is adopted for predicting the features of home area networks. The proposed technique is helpful and could overcome the demerits of existing protocols in relation to scalability, throughput, access delay, and reliability and help in achieving an autonomous home area network (HAN).