The current technologies such as IoT, 5G networks and Fog computing creates a challenge in the efficient management of devices in dynamic conditions. Software-Defined Network (SDN) has been defined as a promising solution for providing efficient network management by decoupling the data and control planes from the network devices and enables programmability of network devices. The major challenge in SDN is identification of number of controllers to be placed and its optimal placements in the network. To address this issue, this work proposes a Traffic Engineering mechanism that leverages the performance of Machine Learning to predict controller numbers by analysing and predicting the controller's traffic. The optimal locations of controllers are identified by using the K-Means++ algorithm. The proposed method is simulated using Mininet and the results depict that the proposed methodology outperforms the existing methodologies in terms of performance parameters.