A machine learning-based controller (MLC) has been developed for a modified double inverted pendulum on a cart (MDIPC). First, the governing differential equations of the system are derived using the Lagrangian method. Then, a dataset is generated to train and test the machine learning-based models of the plant. Different types of machine learning models such as artificial neural networks (ANN), deep neural networks (DNN), long-short-term memory neural networks (LSTM), gated recurrent unit (GRU), and recurrent neural networks (RNN) are employed to capture the system's dynamics. DNN and LSTM are selected due to their superior performance compared to other models. Finally, different variations of the Model Predictive Controller (MPC) are designed, and their performance is evaluated in terms of running time and tracking error. The proposed control methods are shown to have an advantage over the conventional nonlinear and linear model predictive control methods in simulation.