G protein-coupled receptor 40 (GPR40), one of the G protein-coupled receptors that are available to sense glucose metabolism, is an attractive target for the treatment of type 2 diabetes mellitus (T2DM). Despite many efforts having been made to discover small-molecule agonists, there is limited research focus on developing peptides acting as GPR40 agonists to treat T2DM. Here, we propose a novel strategy for peptide design to generate and determine potential peptide agonists against GPR40 efficiently. A molecular fingerprint similarity (MFS) model combined with a deep neural network (DNN) and convolutional neural network was applied to predict the activity of peptides constructed by unnatural amino acids (UAAs). Site-directed mutagenesis (SDM) further optimized the peptides to form specific favorable interactions, and subsequent flexible docking showed the details of the binding mechanism between peptides and GPR40. Molecular dynamics (MD) simulations further verified the stability of the peptide–protein complex. The R-square of the machine learning model on the training set and the test set reached 0.87 and 0.75, respectively; and the three candidate peptides showed excellent performance. The strategy based on machine learning and SDM successfully searched for an optimal design with desirable activity comparable with the model agonist in phase III clinical trials.