Classifying the news articles into 4 categories namely Health, Business, Entertainment, Technology using the following ML models:
- Logistic regression
- Support Vector Machine
- Naive Bayes
- Random forest
- K-NN
Summarize the news articles using Extractive text summarization ( selecting top sentences from the article)
- Text rank algorithm (variation of page rank)
- K-means clustering
- Latent semantic analysis
Scrapped news articles from urls provided by UCI Machine Learning repository link
For scrapping the news articles, Newspaper3k
library built in Python was used. The library contains nlp()
method using which keywords and summary of the news article can be extracted.
Article's content and summary have been scrapped to create the data for the project. Code
The following libraries of Python have to be installed: pandas
, sklearn
, ntlk
, newspaper3k
Run the following command to install
pip install -r requirements.txt
Raw text has unwanted characters (\n,\t,$ etc) and contains stop words (a, an, the) which has to removed before generating the vector representation. The following text preprocessing techniques have been used:
- Converting to lower case
- Removal of stop words
- Tokenize
- Removing contractions (does'nt -> does not)
- Stemming/Lemmatization
S.no | Model | Accuracy in % (BoW) | Accuracy in % (Tf-idf) |
---|---|---|---|
1. | Logistic regression | 95.2 | 94.7 |
2. | SVM | 94.8 | 95.2 |
3. | Naive Bayes | 94.69 | 94.54 |
4. | Random forest | 92.2 | 92.05 |
5. | K-NN | 94.3 | 94.59 |
S.no | Model | Rouge-1 |
---|---|---|
1. | Text rank | 59.2 |
2. | K-means clustering | 54.7 |
3. | Latent semantic analysis | 52.1 |