Ambient backscatter employs existing radio frequency (RF) signals in the environment to support sustainable and independent communications, thereby providing a new set of applications that promote the Internet of Things (IoT). However, nondirectional forms of communication are prone to information leakage. In order to ensure the security of the IoT communication system, in this paper, we propose a machine learning based antenna design scheme, which achieves directional communication from the relay tag to the receiving reader by combining patch antenna with log-periodic dual-dipole antenna (LPDA). A multiobjective genetic algorithm optimizes the antenna side lobe, gain, standing wave ratio, and return loss, with a goal of limiting the number of large side lobes and reduce the side lobe level (SLL). The simulation results demonstrate that our proposed antenna design is well suited for practical applications in physical layer security communication, where signal-to-noise ratio of the wiretap channel is reduced, communication quality of the main channel is ensured, and information leakage is prevented.