Method, medium and system for automatically classifying literature periodicals based on random forest

Through the random forest-based automatic classification method of literature journals and the random forest model is used to classify literature periodically, the problem of lack of effective automated classification methods in the existing technology is solved, efficient and accurate literature classification is achieved, and the need for manual intervention is reduced.

CN119760138APending Publication Date: 2025-04-04SHANGHAI UNIV OF ENG SCI +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411846283.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The existing technology lacks effective automated methods to journal classification of literature, which makes classification efficiency and accuracy difficult to meet modern research needs.

Method used

The automatic classification method of literature journals based on random forests is adopted, and data is cleaned by obtaining the home page text information of the PDF document, and the text data is converted into numerical features using the TF-IDF vectorizer, and the random forest model is input for journal classification. Finally, the literature is stored in the corresponding journal name folder based on the classification results.

Benefits of technology

It realizes automated classification of a large number of PDF documents, improves classification efficiency and accuracy, reduces the need for manual intervention, and has good flexibility and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760138A_ABST
    Figure CN119760138A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic document periodical classification method based on a random forest, a medium and a system, and the method comprises the following steps: obtaining a PDF document of a document to be classified, extracting home page text information of the PDF document, and carrying out the data cleaning of the home page text information, and obtaining text data; converting the text data into numerical features by using a TF-IDF vectorizer to obtain a feature matrix, and inputting the feature matrix into a random forest model to perform periodical classification; and according to a periodical classification result, creating periodical name folders by taking periodical names corresponding to the documents as folder names, and storing the PDF documents of the documents with the same periodical name into the corresponding periodical name folders. Compared with the prior art, the method has the advantages that the literatures are automatically classified according to the periodical names corresponding to the literatures, and the requirement of manual intervention is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of document classification, and in particular to a method, medium and system for automatic classification of literature and periodicals based on random forest. Background Art

[0002] In today's era of information explosion, the results of academic research are published at an increasingly high speed through electronic documents, especially papers stored in PDF format. With the surge in number, how to quickly and effectively classify and manage these documents has become an important research topic. Traditional manual classification methods are not only time-consuming and labor-intensive, but also have a high rate of human error, which makes it difficult to meet the needs of modern research. Therefore, automated document classification technology has gradually become an effective solution to this problem.

[0003] Natural language processing (NLP) technology provides strong support for document classification. By analyzing and understanding the content of documents, the system can use machine learning algorithms to automatically classify documents of different categories. For example, support vector machine (SVM): It is widely used in text classification tasks, can effectively process high-dimensional data, and improve classification performance by maximizing the distance between categories. Logistic regression: A simple and effective linear model suitable for binary or multi-classification tasks, easy to explain and implement. K-nearest neighbor algorithm (KNN): Classification is performed by calculating the distance between samples in the training set and test samples, but it is less efficient on large data sets. Random forest: An ensemble learning method that combines multiple decision trees and obtains the final classification result by voting. Among these algorithms, random forest is widely used in text classification tasks due to its high efficiency and accuracy.

[0004] NLP is a broad field covering language understanding and generation, involving multiple technologies such as text analysis, information extraction, and sentiment analysis. In the process of document classification, NLP can help extract the subject information of the document and perform appropriate preprocessing. Including: Text cleaning: Create clear input for the model by removing special characters, lowercase, and removing stop words. Vocabulary representation methods: including bag of words, word embedding (such as Word2Vec and GloVe), etc. The word embedding method can capture the implicit semantic relationship between words, while the bag of words model is simpler and more intuitive, but ignores the order of words.

[0005] Feature extraction is an important step in converting text into a format that machine learning models can understand. Compared to the bag-of-words model, TF-IDF not only focuses on the frequency of words in a document, but also considers its prevalence in all documents, which can effectively reduce the impact of common words and make features more prominent. TF-IDF calculates the importance of each word in a specific document through a formula, making it perform well in text classification tasks.

[0006] Although various document classification methods have emerged, there are still some shortcomings in document management, especially the lack of document classification methods that automatically classify documents according to their journals to provide researchers with a more convenient information retrieval experience. Summary of the invention

[0007] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and to provide a method, medium and system for automatic classification of literature and periodicals based on random forest, so as to realize automatic classification of literature and periodicals and improve classification efficiency and accuracy.

[0008] The purpose of the present invention can be achieved by the following technical solutions:

[0009] A method for automatic classification of literature journals based on random forests, comprising the following steps:

[0010] Obtaining a PDF document of a document to be classified, extracting the homepage text information of the PDF document, and performing data cleaning on the homepage text information to obtain text data;

[0011] The text data is converted into numerical features using a TF-IDF vectorizer to obtain a feature matrix, and the feature matrix is ​​input into a random forest model for journal classification;

[0012] According to the journal classification result, a journal name folder is created with the journal name corresponding to the document as the folder name, and the PDF documents of the document with the same journal name are stored in the folder corresponding to the journal name.

[0013] Furthermore, the homepage text information includes multiple ones of journal name, publication date, author information, affiliated institution, paper name, abstract, article introduction and technical summary.

[0014] Furthermore, the extracted homepage text information is cleaned using regular expressions and other string processing methods.

[0015] Furthermore, the specific steps of data cleaning include deleting all unnecessary special characters, punctuation marks and malformed texts, converting the texts to lowercase and removing stop words.

[0016] Furthermore, in the process of obtaining the feature matrix, the maximum number of features is set to 7000 and the minimum document frequency is set to 5.

[0017] Furthermore, the classification results are visualized by matplotlib to obtain a bar graph, wherein the horizontal axis of the bar graph is the name of each journal, and the vertical axis is the number of PDF documents in each journal.

[0018] Furthermore, when training the random forest model, the PDF documents of several documents are classified and stored in folders according to the journal names; the homepage text information of each PDF document is extracted, and the homepage text information is cleaned to obtain text data; the text data is divided into a training set and a test set, and a TF-IDF vectorizer is created to convert the text data into numerical features to obtain a feature matrix; the feature matrix of the training set is input into the random forest model for classification prediction training, and the trained random forest model and TF-IDF vectorizer are saved through the joblib library.

[0019] Furthermore, when training the random forest model, the classification results of the random forest model are visualized and analyzed using a confusion matrix to determine the classification performance indicators of the random forest model, wherein the classification performance indicators include multiple ones of precision, recall rate, F1 score and support.

[0020] Furthermore, the computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it can implement the random forest-based automatic classification method for literature and journals as described in any one of claims 1 to 8.

[0021] According to another aspect of the present invention, there is provided a system for automatic classification of literature and periodicals based on random forest, comprising:

[0022] A text data acquisition module is used to acquire the PDF document of the document to be classified, and perform data cleaning on the text in the PDF document to obtain text data;

[0023] A random forest classification module, which converts the text data into numerical features using a TF-IDF vectorizer to obtain a feature matrix, and inputs the feature matrix into a random forest model for journal classification;

[0024] The PDF document storage module is used to create a journal name folder with the journal name corresponding to the document as the folder name according to the journal classification result, and store the PDF document of the document with the same journal name in the corresponding journal name folder.

[0025] Compared with the prior art, the present invention has the following beneficial effects:

[0026] 1. The present invention obtains text data by extracting the homepage text information of the PDF document of the document to be classified and performing data cleaning; converts the text data into numerical features using a TF-IDF vectorizer to obtain a feature matrix, and inputs the feature matrix into a random forest model for classification; creates a journal name folder based on the classification result with the journal name corresponding to the document as the folder name, and stores the PDF documents of the document with the same journal name in the corresponding journal name folder; establishes a complete text extraction and classification process, which can batch process a large number of PDF documents in a relatively short time, realize automatic classification, and greatly reduce the need for manual intervention.

[0027] 2. The present invention can maintain a high classification accuracy in the documents to be classified through the trained random forest model, visualize the classification results through matplotlib, obtain a bar chart, and adjust the most suitable hyperparameter combination by visualizing the influence of hyperparameters on the accuracy. The classification standards can be easily adjusted for documents in different fields, and it has good flexibility and scalability. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 This is a flow chart of the random forest-based automatic classification method for literature and periodicals proposed in the present invention. DETAILED DESCRIPTION

[0029] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.

[0030] Abbreviations involved:

[0031] Term Frequency-Inverse Document Frequency, TF-IDF

[0032] Example 1

[0033] This embodiment provides a method for automatic classification of literature and periodicals based on random forest. Figure 1 As shown, the following steps are included:

[0034] S1. Obtain the PDF document of the document to be classified, extract the home page text information of the PDF document, and perform data cleaning on the home page text information to obtain text data.

[0035] The saved random forest model and TF-IDF vectorizer are loaded through the joblib library, and all PDF documents in the specified folder are traversed to extract the homepage text information in turn. The extracted text information is processed through regular expressions and other string processing methods to delete all unnecessary special characters, punctuation marks or incorrectly formatted text (such as extra spaces), and then all texts are uniformly converted to lowercase to ensure the neatness of the text. Use industry-standard stop word lists (such as the list provided by the NLTK library) to remove common meaningless words in the text to obtain a text data with a clear structure and concentrated information. The text data contains two items: text and label (journal name), and is saved as a CSV file. The homepage text information generally includes the journal name, publication date, author information, affiliated institution, paper name, abstract and introduction of the article, as well as some main information and technical summary.

[0036] S2. Use TF-IDF vectorizer to convert text data into numerical features to obtain feature matrix, and input the feature matrix into random forest model for journal classification.

[0037] TfidfVectorizer is used to vectorize the text of the document and generate a TF-IDF matrix. This process effectively extracts key numerical features by setting the maximum number of features to 7000 and the minimum document frequency (min_df) to 5, converts them into a feature matrix, and inputs the feature matrix into the random forest model for journal classification.

[0038] S3. According to the journal classification results, a journal name folder is created with the journal name corresponding to the document as the folder name, and the PDF documents of the documents with the same journal name are stored in the corresponding journal name folder.

[0039] The classification results are visualized through matplotlib to obtain a bar chart. The horizontal axis of the bar chart is the name of each journal, and the vertical axis is the number of PDF documents in the folder of each journal name.

[0040] The training steps of the random forest model include:

[0041] The PDF documents of several documents are classified and stored in folders according to the journal names; folders with journal names are manually created based on the downloaded documents, and classified and stored according to different sources. This storage method allows text data to be directly created according to the extracted and cleaned text and labels (journal names) after text extraction.

[0042] Extract the first page text information of each PDF document, perform data cleaning on the first page text information, and obtain text data; use the pdfplumber library to process the PDF document, traverse the specified folder structure, and check the PDF documents in each journal folder one by one to ensure that the first page information of all relevant documents is fully extracted. The extracted text and the corresponding journal tags form a structured data set.

[0043] 80% of the text data is used as a training set and 20% as a test set. A TF-IDF vectorizer is created to convert the text data into numerical features to obtain a feature matrix. TfidfVectorizer is used to vectorize the text of the document to generate a TF-IDF matrix. This process effectively extracts key text features by setting the maximum number of features to 7000 and the minimum document frequency (min_df) to 5. This operation aims to improve the model's ability to capture text information and ensure that the classifier can be trained based on sufficient features. The two parameters are finally obtained by adjusting the maximum number of features and the minimum document rating rate again and again. The dataset is split into a test set at a ratio of 20%, and the rest is used for training. This splitting strategy ensures the independence of training and test data while ensuring the generalization ability of the model. In order to deal with the potential class imbalance problem, class weights are calculated and applied to balance the influence of each class during the training process, thereby improving the classification performance of the model on different classes. The model is trained with 300 decision trees to improve classification performance, and "balanced" class weights are used to ensure the effectiveness of the model in various situations.

[0044] The feature matrix of the training set is input into the random forest model for classification prediction training, and the classification effect of the random forest model is verified on the test set. The classification results of the model are visualized and analyzed using the confusion matrix to determine important indicators such as the model's accuracy, precision, and recall.

[0045] In order to verify the classification effect of the random forest model, the classification performance is comprehensively evaluated through the test set. The classification results of the model are visualized and analyzed using the confusion matrix to determine important indicators such as the model's precision, recall rate, F1 score, and support. Table 1 shows these evaluation indicators for several journal categories after random forest training.

[0046] Table 1 Evaluation indicators

[0047]

[0048] The precision, recall, and F1 scores of some journal categories are as high as 1, while those of others are 0. This may be because the number of samples in some categories in the text data is much larger than that in other categories. The random forest model may perform better on most categories, resulting in deviations in precision and recall.

[0049] This embodiment not only tries the random forest algorithm, but also the SVM and KNN algorithms and uses the above evaluation indicators for evaluation. The evaluation results are shown in Table 2, which shows that the random forest algorithm has a higher accuracy, with an accuracy rate of up to 89%.

[0050] Table 2 Classification algorithm results

[0051]

[0052]

[0053] For the convenience of subsequent use, the trained random forest model and TF-IDF vectorizer are saved to disk. By using the joblib library, the persistence of the model is simplified to a single process, ensuring the convenience and efficiency of subsequent calls.

[0054] Use the random forest model to predict the literature classification. According to the prediction results, create a corresponding journal name folder (if it does not exist), and move the PDF document to the corresponding folder. At the same time, record the number of files in each category, and use matplotlib to draw a bar chart to show the number of PDF files in each category. The horizontal axis of the bar chart is the journal name, and the vertical axis is the number of PDF documents in each journal.

[0055] Example 2

[0056] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for automatic classification of literature and periodicals based on random forest proposed in Embodiment 1 can be implemented.

[0057] The rest is the same as in Example 1.

[0058] Example 3

[0059] This embodiment provides a system for automatic classification of literature and periodicals based on random forest, including:

[0060] The text data acquisition module is used to obtain the PDF document of the document to be classified, perform data cleaning on the text in the PDF document, and obtain text data;

[0061] The random forest classification module uses the TF-IDF vectorizer to convert text data into numerical features to obtain a feature matrix, which is then input into the random forest model for journal classification;

[0062] The PDF document storage module is used to create a journal name folder with the journal name corresponding to the document as the folder name according to the journal classification results, and store the PDF documents of the document with the same journal name in the corresponding journal name folder.

[0063] The rest is the same as in Example 1.

[0064] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.

Claims

1. A method for automatic classification of literature and periodicals based on random forest, characterized in that: The following steps are involved: Obtaining a PDF document of a document to be classified, extracting the homepage text information of the PDF document, and performing data cleaning on the homepage text information to obtain text data; The text data is converted into numerical features using a TF-IDF vectorizer to obtain a feature matrix, and the feature matrix is ​​input into a random forest model for journal classification; According to the journal classification result, a journal name folder is created with the journal name corresponding to the document as the folder name, and the PDF documents of the document with the same journal name are stored in the folder corresponding to the journal name.

2. The method for automatic classification of literature and periodicals based on random forest according to claim 1, characterized in that: The home page text information includes multiple ones of journal name, publication date, author information, affiliated institution, paper name, abstract, article introduction and technical summary.

3. The method for automatic classification of literature and periodicals based on random forest according to claim 1, characterized in that: The extracted homepage text information is cleaned using regular expressions and other string processing methods.

4. The method for automatic classification of literature and periodicals based on random forest according to claim 3 is characterized in that: The specific steps of data cleaning include deleting all unnecessary special characters, punctuation marks and malformed text, converting the text to lowercase and removing stop words.

5. The method for automatic classification of literature and periodicals based on random forest according to claim 1, characterized in that: In the process of obtaining the feature matrix, the maximum number of features is set to 7000 and the minimum document frequency is set to 5.

6. The method for automatic classification of literature and periodicals based on random forest according to claim 1, characterized in that: The classification results are visualized by matplotlib to obtain a bar graph, wherein the horizontal axis of the bar graph is the name of each journal, and the vertical axis is the number of PDF documents in each journal.

7. The method for automatic classification of literature and periodicals based on random forest according to claim 1, characterized in that: When training the random forest model, PDF documents of several documents are classified and stored in folders according to journal names; the homepage text information of each PDF document is extracted, and the homepage text information is cleaned to obtain text data; the text data is divided into a training set and a test set, and a TF-IDF vectorizer is created to convert the text data into numerical features to obtain a feature matrix; The feature matrix of the training set is input into the random forest model for classification prediction training, and the trained random forest model and TF-IDF vectorizer are saved through the joblib library.

8. The method for automatic classification of literature and periodicals based on random forest according to claim 1, characterized in that: When training the random forest model, the classification results of the random forest model are visualized and analyzed using a confusion matrix to determine the classification performance indicators of the random forest model, where the classification performance indicators include multiple ones of precision, recall rate, F1 score and support.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it can implement the random forest-based automatic classification method for literature and periodicals as described in any one of claims 1 to 8.

10. A literature and periodical automatic classification system based on random forest, characterized in that: include: A text data acquisition module is used to acquire the PDF document of the document to be classified, and perform data cleaning on the text in the PDF document to obtain text data; A random forest classification module, which converts the text data into numerical features using a TF-IDF vectorizer to obtain a feature matrix, and inputs the feature matrix into a random forest model for journal classification; The PDF document storage module is used to create a journal name folder with the journal name corresponding to the document as the folder name according to the journal classification result, and store the PDF document of the document with the same journal name in the corresponding journal name folder.

Citation Information

Cited By

  • Transform model-based literature classification method and system and electronic equipment

    CN122019482A