Programming by Demonstration(PBD) applies in the industry as a method of human-robot collaboration for assembly, such as placing, inserting, and screwing; however, PBD has not received much attention in commercial electronic product assembly. There is little work on integrating a strategy to optimize trajectory planning, which is an initial step of PBD. Most recent related works improving PBD performance focus on taking care of numerous demonstration samples from motion-sensing devices under time consumption, distance, and other related criteria. However, it is necessary to integrate a strategy to optimize the performance of precise assembly tasks. We proposed a framework with two custom algorithms to pre-process and classify contactless demonstration performance in this research work. It verified that these algorithms could more effectively generate optimal motion paths in criteria of distance, smoothness, and trajectory variance than canonical methods. Machine learning methods, including the Convolutional neural network(CNN), Artificial Neural Network(ANN), and Support Vector Machine(SVM), are feasible to predict the further performance that the best motion path with accuracy ranging from 80% to 85% accuracy. Also, CNN performs better than ANN and SVM. Among CNN methods, the DarkNet yields the highest accuracy rate of 85%. Future work includes the hybrid CNN/ANN algorithm, which may yield higher accuracy in prediction. Also, the proposed algorithms may apply to robots with dual assembly arms which mimic human arms.