In conserving energy during routing in Wireless Sensor networks (WSN), Software Define Networking (SDN) was integrated into WSN and referred to as Software Defined Wireless Sensor Network (SDWSN). This is to exclude sensor nodes from routing decisions. Thus, enabling the SDN controller to handle hierarchical routing decisions. The existing WSN hierarchical routing protocols are not adequate for SDWSN due to their unbalanced characteristics in clustering and cluster head selection. In this regard, a Balanced Machine Learning-based Clustering (B-MLC) algorithm is proposed and compared with two closely related hierarchical algorithms (LEACH and FCM) for routing. The outcome indicated that, the B-MLC algorithm maintained a low average packet loss and is efficient in network lifetime elongation, with an average improvement of 60.4% and 89.8% respectively, over LEACH and FCM. Hence, the B-MLC can be adopted in SDWSN for complex monitoring applications.