This letter introduces a new technique to optimize the alignment of a W-band quasi-optical higher order mode RF generator. Using linear regression (LR) and deep neural networks (DNNs), the system compares the measured beam patterns with pretrained misalignment data from mode generator simulations to achieve an optimized solution. The method ensures a well-aligned beam pattern with 96.8% mode purity exhibiting excellent repeatability, with a mode purity error below 1%. Compared with previous alignment systems, this approach reduces alignment time by over 20 times.