Fostering idealogical and polical education via knowledge graph and KNN model: an emphasis on positive psychology | BMC Psychology


The overall framework of the model

Based on the methods of text classification and cluster analysis, this paper analyzes the mapping relationship between questionnaire and educational psychology. Combined with the questionnaire data, the personal mastery value of students is extracted, which is then transformed into the learning characteristics in different educational psychology. By using the clustering algorithm, students can be divided into several categories according to the differences in learning characteristics. In this paper, the feasibility of clustering algorithm is verified, and the learning characteristics of each class of students are analyzed. The overall framework of the model is shown in Fig. 1.

Fig. 1
figure 1

The overall framework of the model

Prior to integrating educational psychology into teaching, it is imperative to comprehend the nuanced relationship between them. This paper introduces a knowledge graph model grounded in clustering analysis. Within this model, the questionnaire-psychological mapping relationship is derived through a KNN model, and psychological characteristics are scrutinized via a clustering algorithm.

Educational psychology in this model is categorized into three main facets: teacher psychology, student psychology, and the communication psychology between teachers and students. Within the realm of teacher psychology, attributes such as personality charm, teacher prestige, and teaching effectiveness are considered. Student psychology encompasses two key dimensions: self-consciousness and personality tendency. Among these relationships, the teacher-student relationship emerges as the foundational interpersonal dynamic in the teaching context.

The questionnaire-psychological mapping relation extraction based on KNN

Using the text classification algorithm in text analysis, the k-NN model [24, 25] classifies the questionnaires into different educational psychology firstly. If a questionnaire contains multiple educational psychology, it is impossible to determine the learning characteristics of students in multiple educational psychology, so each questionnaire is considered to be an educational psychology. The data in the questionnaire are analyzed in depth to obtain each the psychological learning characteristics of students. In order to facilitate the analysis, the correlation between the questionnaire and the psychological point is represented by the questionnaire-psychological matrix K, as shown in Formula 1. Formula 1 shows.

$$K = \left[ \beginarray*20c k_11 & k_21 & & k_1n \\ k_21 & k_22 & & k_2n \\ & & & \\ k_m1 & k_m2 & & k_mn \\ \endarray \right]$$


where \(k_mn\) denotes whether questionnaire m belongs to psychology n, m denotes the number of questionnaires, and n denotes the type of educational psychology. When \(k_mn = 1\), it means that questionnaire m belongs to psychology n.

The classification model is used to process the extracted text features. Due to the large number of questionnaires and the high dimension of text features, the simplest classification model is selected to deal with the evaluation questions. The extracted text features are obtained by using the k-NN model, and the text features of the test questions are divided into two types. The subordinate relationship between questionnaire data and psychology in training samples is given by authoritative experts in this field. The text features of the training samples have a classification label, each of which represents a psychology.

The analysis of psychological characteristics based on knowledge graph

The clustering analysis is the process of dividing the set of abstract objects into multiple clusters composed of similar objects. The common clustering analysis algorithms are hierarchical clustering method and DBSCAN density method [26], the DBSCAN density clustering algorithm is selected in this paper, which can divide regions with enough high density into clusters [27].

Combined with text classification, the questionnaire can be classified into educational psychology, and the questionnaire-psychological learning characteristic matrix can be obtained. According to the psychological learning characteristics of each students, the DBSCAN clustering algorithm is used to cluster the students, and the questionnaire-psychological characteristic matrix after clustering can be obtained.

There are three forms of the learning characteristics in educational psychology, which are the high standard, the medium standard and the low standard. \(s_t\) represents the mastery of educational psychology, as shown in Formula 2.

$$s_t = (s_t1 + s_t2 + \cdot \cdot \cdot + s_tn )/h$$


Where \(s_t\) values in the interval [0, 1]. A higher value indicates a higher degree of mastery in this psychology. If \(s_t \in [0.7,1]\), it signifies that students have a proficient grasp of this educational psychology, falling into the category of high standards. If \(s_t \in [0.3,0.7]\), it suggests that students’ mastery level in this educational psychology is average, corresponding to the middle standard. If \(s_t \in [0,0.3]\), it implies that students’ mastery level in this educational psychology is not satisfactory, categorizing them under the low standard.

The knowledge graph is composed of entities and the relationships between them, the relationships between entities are the edges in the knowledge graph [28]. Through the clustering analysis of learning characteristics, multiple student classes can be obtained. Then the relationship between students is analyzed, and each student in each category has a learning characteristic value in each psychology. In order to avoid the inaccuracy of the constructed knowledge graph, the authority and rationality of the model are verified according to the difference of learning stability [29].

In order to verify the effect of knowledge graph, the stability of educational psychology is introduced, and its calculation is shown in Formula 3.

$$Mu_tx = (sk_tx – ck_zx )^2$$


Where \(Mu_tx\) represents the stability value of educational psychology, which indicates the learning characteristics of students in educational psychology.

The educational psychological balance is introduced to evaluate the model, and its calculation is shown in Formula 4.

$$Mu_t = \frac\sum\limits_1^n Mu_tx n$$


Where \(Mu_t\)\(Mu_t\) represents the variance between all learning characteristics and the learning characteristics of the student.

Prediction system design

The knowledge graph model based on cluster analysis is introduced above, which can effectively predict the relationship between these two concepts. Then, the system module will be designed in detail from four aspects, which are the software development environment and experimental data, the structure design, the data acquisition module and the knowledge display and storage.

The background language of the system is Python that has low learning cost and many mature frameworks, and the Django framework of Python language is used in this paper. According to the size and functional requirements of system, the Django framework is selected in this paper. The database selected in this paper is ProQuest Psychology Database, which is the most comprehensive full-text database of full-text journals of pedagogy and psychology in the world. The data used in this paper includes two parts, one is the basic information data of students, the other is the answer record data of students.

The Django architecture is used in this system, which not only has a clear division of labor, but also does not interfere with each other. The method used in this paper can reduce the coupling of the system, whose architecture is shown in Fig. 2.

Fig. 2
figure 2

This system consists of two modules, one is the management module, and the other is the analysis module. The management module implements student information management and evaluation data management, and the analysis module can not only realize the matching of questionnaire and educational psychology, but also realize the extraction of characteristics and the construction of knowledge graph.

Firstly, the system selects some modules as the initial URL, and then the HTML structure can be viewed through the developer mode. By custom page link parser, you can get other URLs contained in this module, which is then stored in the site URL list and stored locally in text format. When crawling the text, the text judgment mechanism is added in order to eliminate non-ideological and political data. Before storing the text locally, it is necessary to determine whether there are ideological and political terms in the text. If there are no ideological and political terms, no operation is carried out, the system will continue to access other URLs until the URL queue is empty.

The calculation of logical unit is shown in Formulas (5) to (7).

$$i = \delta (w_t \cdot [h_t \,,\,x_t ] + d_t )$$


$$f = \delta (w_f \cdot [h_t \,,\,x_t ] + d_f )$$


$$o = \delta (w_o \cdot [h_t \,,\,x_t ] + d_o )$$


Where \(i\) represents the input gate, \(f\) represents the output gate, \(o\) represents the forget gate, \(\delta\) represents the activation function, \(d_t\)\(d_f\) and \(d_o\) represent the offset vector.

The knowledge storage

The representation forms of knowledge graph are RDF triples and graph database. The RDF can store data in the form of metadata, and the graph database stores and inquires data in the form of graphs. This paper selects RDF triples to represent the ideological and political knowledge triples, and the API is used to store RDF files into the graph database.

Then, it is necessary to build a data interpreter in RDF files and graph databases to complete the knowledge storage. Firstly, the API is needed to parse the obtained RDF files and encapsulate the subjects, in which the RDF files are used to encapsulate representation subjects, predicates, and objects. Secondly, the encapsulated triple objects are connected to the graph database, then we need to parse it with a built data parser. Finally, the relevant parameters of the graph database are set, and the API is used to store node relationships in batches inside the server. The flowchart is shown in Fig. 3.

Fig. 3
figure 3

The flow chart of knowledge storage


Leave a Reply

Your email address will not be published. Required fields are marked *