Since the beginning of the 21st century, with the development of information technology, researchers in various fields have gradually increased their research on human emotion and behavior. The current research mechanism used in emotion and behavior research is artificial intelligence technology. Through the literature survey and data analysis in related fields, it is found that the acquisition of human emotions and behaviors will be carried out through facial feature algorithm for point capture and combined with machine learning for output detection and analysis. Among them, the detection process requires machine learning of artificial intelligence first. This paper firstly analyzes and summarizes the advantages of Python programs at this stage and completes the preliminary work of system construction by setting and installing platform parameters. In the research process, this paper uses the existing algorithm to apply the
σ
E
value algorithm to the samples and conducts preliminary tests. The overall detection values in the test data are relatively average, and there are still differences in the samples. At the same time, we compare the
U
E
and
T
E
detection algorithms according to the output
Y
value of the algorithm in the machine learning. The detection rate of some emoticons in the
U
E
algorithm is high, but the detection rate of other emoticons is low. Finally, according to the limitation of the output method in the mathematical formula, a new algorithm
σ
x
of taking the weighted sum and taking the logarithm and then taking the square root is proposed again. According to the statistical analysis, the overall average value of the final algorithm has been improved, and the overall detection rate is about 80%; compared with the
T
E
and
U
E
algorithms, the overall detection frequency fluctuates less. The
σ
x
algorithm in the frequency fluctuation data table in the paper is also superior to the existing algorithms in machine learning, sample testing, and data in the frequency fluctuation. Our next direction will be to use the Python main program to perform AI automatic facial emotion detection work by combining the new algorithm
σ
x
with the
V
value, DWT, and CNN algorithm in the facial recognition feature through machine learning.