Hydrogels are highly promising due to their soft texture and excellent biocompatibility. However, the designation and optimization of hydrogels involve numerous experimental parameters, posing challenges in achieving rapid optimization through conventional experimental methods. In this study, we leverage machine learning algorithms to optimize a dual-network hydrogel based on a blend of acrylamide (AM) and alginate, targeting applications in flexible electronics. By treating the concentrations of components as experimental parameters and utilizing five material properties as evaluation criteria, we conduct a comprehensive property assessment of the material using a linear weighting method. Subsequently, we design a series of experimental plans using the Bayesian optimization algorithm and validate them experimentally. Through iterative refinement, we optimize the experimental parameters, resulting in a hydrogel with superior overall properties, including heightened strain sensitivity and flexibility. Leveraging the available experimental data, we employ a classification algorithm to separate the cutoff data. The feature importance identified by the classification model highlights the pronounced impact of AM, ammonium persulfate, and N,N-methylene on the classification outcomes. Additionally, we develop a regression model and demonstrate its utility in predicting and analyzing the relationship between experimental parameters and hydrogel properties through experimental validation.